minamorl / rex

Observable pattern in nim
22 stars 1 forks source link

Subjects #1

Closed PhilippMDoerner closed 5 months ago

PhilippMDoerner commented 5 months ago

First up I want to state I'm a huge fan! Reactive programming was one of the things I was personally missing in nim as an effortless way of keeping specific values "in sync" with one another - particularly as a somewhat advanced webdev with plenty of RXJS experience. If I thus come off as a bit over-eager by opening a bunch of issues I apologize, these are mostly the things that came into my mind by just reading the code and playing around a bit with it.

Second to the actual topic at hand, I would love to also see Subjects eventually become part of this.

Subjects are immensely useful for allowing you to explicitly control when to push new values. For example You may have a piece of text on a page that says "Hello <name>" together with a text-input field to type in a name. You might be able to listen to changed events on that input field and therefore want to automatically update the string <name> when such a thing happens. You could do that reactively by having a "name" subject and whenever a changed event on the input fires you push a new value into the Subject which updates e.g. <name>.

PhilippMDoerner commented 5 months ago

I have come to the realization that you actually can use the observables themselves like subjects by simply never using enable and just always using next. Therefore you were actually way ahead of my thinking in that regard :smile: