This package has been deprecated

Author message:

feathers-rx has been renamed to feathers-reactive

feathers-rx

0.1.1 • Public • Published

feathers-rx

Build Status

Reactive API extensions for Feathers

About

feathers-rx turns a Feathers service call into an RxJS observables that automatically updates on real-time events.

Simple example

const feathers = require('feathers');
const memory = require('feathers-memory');
const rx = require('feathers-rx');

const app = feathers()
  .configure(rx())
  .use('/messages', memory());

const messages = app.service('messages');

messages.create({
  text: 'A test message'
}).then(() => {
  // Get a specific message with id 10. Emit the message data once it resolves
  // and every time it changes e.g. through an updated or patched event
  messages.get(0).subscribe(message => console.log('My message', message));

  // Find all messages and emit a new list every time anything changes
  messages.find().subscribe(messages => console.log('Message list', messages));

  setTimeout(() => {
    messages.create({ text: 'Another message' }).then(() =>
      setTimeout(() => messages.patch(0, { text: 'Updated message' }), 1000)
    );
  }, 1000);
});

Will output:

My message { text: 'A test message', id: 0 }
Message list [ { text: 'A test message', id: 0 } ]
Message list [ { text: 'A test message', id: 0 },
  { text: 'Another message', id: 1 } ]
My message { text: 'Updated message', id: 0 }
Message list [ { text: 'Updated message', id: 0 },
  { text: 'Another message', id: 1 } ]

Changelog

0.1.0

  • Initial release

License

Copyright (c) 2016

Licensed under the MIT license.

Package Sidebar

Install

npm i feathers-rx

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • daffl