Search code examples
angularjsmessage-queuerxjsmessage-bus

Using RxJS to implement MessageBus for communication between angularjs modules


Can I create a pub/sub message message queue with RxJS inside angulajs application. I have for example two modules: ModuleA ModuleB They exists as separate npm package but connected in ModuleC - it's the main shell.

I don't want to create a dependency as ModuleD and create a tight coupling between the modules. So my thought is to create a message bus using RxJS. Is it possible?

I presume an API will look like that: RxQueue.subscribe("name:of:the:queuemessage", handler => { handler.result } ); RxQueue.create("name:of:the:queuemessage", (observer) => { // implementation of usual Rx subscribtion })


Solution

  • I think this might be closest to what you are asking for:

    rxmqjs/rxmq.js: JavaScript pub/sub library based on RxJS
    https://github.com/rxmqjs/rxmq.js
    https://www.npmjs.com/package/rxmq

    Not angular specific, but I consider that a good thing.