real-time-observer

1.0.3 • Public • Published

RealTimeObserver

Author : kingsae1004@gmail.com

What is RealTimeObserver?

real-time-observer is a plugin of node module to subscribe lots of databases. but this beta feature is available to use MongoDB

How to use?

At first, Must initailize Observer class with config (currently support only for MongoDB)

const { RTMongoObserver } = require("./index.js");
const observer = new RTMongoObserver({
  SERVER_TYPE: "MONGODB",
  SERVER_URL: "",
  SERVER_ID: "",
  SERVER_PW: "",
  MONGO_DATABASE: "",
  MONGO_COLLECTION: "",
});

And then optionally you can define collection name. If not defined, load the config property (MONGO_COLLECTION)

observer.getCollection("COLLECTION_NAME");

This way is to subscribe observer (MongoDB collection)

// subscribe database
observer.subscribe(observer.getCollection()).then((data) => {
  console.log(data);
});

I recommend unsubscribe after (unmount/disolve/disable ..) case

// Remove Listner
setTimeout(() => {
  observer.unsubscribe(observer.getCollection());
}, 2000);

How to use test?

npm run test

Readme

Keywords

none

Package Sidebar

Install

npm i real-time-observer

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

19.4 kB

Total Files

5

Last publish

Collaborators

  • kingsae1