Aurelia 2 and Rxjs

I’m really getting into rxjs. Was wondering if there will be more built-in support for it in Aurelia 2?

I’ve found I want to express everything as observables now. Have been using the async binding here:

Is something like this going to be built into Aurelia 2? I would also like two-way bindings to use a Subject and expose an Observable. Routing would also be better just expressed as an Observable when the url changes.

Sidenote, I noticed that the async binding subscribes twice, because binding.updateTarget gets called twice when composing the view. Any idea why this is?

Thanks,
Jon

1 Like

As far as a I recall there have been plans to add bindings to observables and promises natively to Au2 according to some internal discussions. It’s just not on a high prio currently. I doubt though it would make it into the Router but that can be pretty easily done by yourself by creating an observable from router events

1 Like

You guys might be interested to know that while looking at new ESNext features, I saw the Observable feature which is at Stage 1 (very early) and by looking at the Kangax Table apparently TypeScript already supports , but I have no clue how to (simply doing typeof Observable just fails from what I can see, or maybe it’s just my linter). Anyhow… it will be interesting to have this native into the browser, of course RxJs brings a lot more compare to what the native one will do but still having a native version of it is interesting for simple pub/sub

2 Likes

It’s there for quite a while but certainly a good step in the right direction. Rxjs brings a lot to the table but aside from Subjects and a handful of operators (pluck, map, first/last, skip/take), which can be implemented hopefully easy enough with map/reduce, I’d happily go native asap

4 Likes

What about Aurelia Store? https://aurelia.io/docs/plugins/store/

1 Like

We’ve been using Aurelia Store for over a year now, but only just realizing the full potential of Rxjs. I think the documentation for the store could be better in that respect. The benefits of rx are not well represented. For example, the subscribing and unsubscribing in the view model makes it looks like just another way to get your data. It doesn’t show the real power of rx, which is composing observables and removing complexity (especially temporal coupling).

1 Like

Yep that’s right, it’s been kept intentionally small since I feel it would overcrowd the already long docs. While RxJs is in my opinion fantastic once you get into there is a learning curve to that so that’s why the bare minimum of subscriptions is there to soften that curve. If there is any resources you would see fit though we perhaps could add another small section towards the end to link those up

1 Like