# How do we create a Node from an RxJs Observable?

**URL:** <https://discourse.nodered.org/t/how-do-we-create-a-node-from-an-rxjs-observable/40154>\
**Category:** Developing Nodes\
**Created:** [1 February 2021 08:16 UTC](https://discourse.nodered.org/t/how-do-we-create-a-node-from-an-rxjs-observable/40154 "2021-02-01T08:16:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeevan900929](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeevan900929/32/36306_2.png) [@jeevan900929](https://discourse.nodered.org/u/jeevan900929)\
**Post date:** [1 February 2021 08:16 UTC](https://discourse.nodered.org/t/how-do-we-create-a-node-from-an-rxjs-observable/40154/1 "2021-02-01T08:16:02Z")

</div>

Is there a way to emit a message stream in a node by subscribing to an Observable?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [1 February 2021 10:17 UTC](https://discourse.nodered.org/t/how-do-we-create-a-node-from-an-rxjs-observable/40154/2 "2021-02-01T10:17:59Z")

</div>

I'm sure you could create a node that uses RxJs Observable.

Is that what you are trying to do - create a custom node? (you posted this in the "Creating Nodes" section.

OR

Are you talking about using an Observable in your flows?

---

<div class="post-metadata">

**Author:** ![jeevan900929](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jeevan900929/32/36306_2.png) [@jeevan900929](https://discourse.nodered.org/u/jeevan900929)\
**Post date:** [2 February 2021 01:28 UTC](https://discourse.nodered.org/t/how-do-we-create-a-node-from-an-rxjs-observable/40154/3 "2021-02-02T01:28:43Z")

</div>

Yes, creating a custom node.

Would that mean:

1. Subscribing to the observable, and at every next(), a message payload is sent.
2. When the node is closed, the observable is unsubscribed from.

Is there some asynchronous implementation needed for this case?

Thanks

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [2 February 2021 08:09 UTC](https://discourse.nodered.org/t/how-do-we-create-a-node-from-an-rxjs-observable/40154/4 "2021-02-02T08:09:43Z")

</div>

Depends what you are trying to achieve. What do you have in mind?

custom Nodes have the input event - you could do whatever you need based on topic  
e.g. It could be that you use a msg.topic as a control (e.g. if msg.topic == "setup", if msg.topic == "next", if msg.topic == "clear")

custom Nodes have a close event - you should clean up at this point.

Regarding async, when the observable fires, you can call node.send(msg) to emit the observables next item for example.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 February 2021 08:10 UTC](https://discourse.nodered.org/t/how-do-we-create-a-node-from-an-rxjs-observable/40154/5 "2021-02-16T08:10:34Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
