qoole
qoole

Reputation: 31

Interconecting reSolve to another system

I need to connect to an API of another system via a RESTful interface that will be providing events via a websocket connection.

I am using a javascript library to do all the heavy lifting with this other system. I am interested as to the best way to join that system and reSolve.

For example, the other system deals with real-world events and when one these events occurs I want it to feed into reSolve to alter the state.

These events are handled through standard .on handlers.

The inverse is also required, I need to be able to send commands to this other system from reSolve.

My initial thoughts would be in a saga, but I'm unsure if that is the preferred way of doing things.

Thank you for any support you are able to offer.

Upvotes: 3

Views: 59

Answers (2)

Roman Eremin
Roman Eremin

Reputation: 1451

As I understand, you have some process that reacts on events in the external system. On these events you can just send a command to reSolve app (a trivial command RECORD_EXTERNAL_EVENT that just stores a payload). Then you can use all other reSolve parts to react on such event within reSolve.

In the inverse scenario - when you send events to an external system - you can create a saga with some kind of "send event" side effect, as Anton suggested.

Upvotes: 1

Anton Zhukov
Anton Zhukov

Reputation: 11

I need to be able to send commands to this other system from reSolve.

You can use fetch (https://www.npmjs.com/package/isomorphic-fetch) in api-handlers https://reimagined.github.io/resolve/docs/api-handlers .

Alternatively, you can use side-effects in sagas https://reimagined.github.io/resolve/docs/sagas

Upvotes: 0

Related Questions