Stateless reactive ForEach?

Hey all,

I was assuming that Select [Reactive.Observable] was ForEach [Reactive]'s stateless twin. Am I wrong?

I’m attempting to refactor the Updates part of GammaLauncher, which is a massive chain of reactive ForEach. Because they’re stateful, I cannot wrap them in static operations, so I started replacing those ForEach with Select [Reactive.Observable], but it looks like the events don’t flow through the pipe anymore.

Re-replacing those with ForEach [Reactive] makes it work again, but that’s not really viable for me since I’m attempting to modularize this whole thing. I also had vvvveird experiences in the past using stateful nodes in reactive pipelines, which is why I don’t want to wrap those in Process nodes.

You can check the current state of thing in the repository at this commit.

Repro steps:

  • Open GammaLauncher
  • Press F9 to ignore the Returned interface System.__ComObject does not implement IDWriteFactory exception (bug report incoming) (you’ll get a ghost window)
  • Navigate to the UpdatesTabRuntime patch
  • There’s a Select right after the ToBackground node. When starting the launcher or when clicking the Check For Updates button in the UI, you should see Checking for remote builds… logged in the console: this does not happen.
  • Replace that Select node with a reactive ForEach, press F9 : you should now see this message in the Console.

Can anyone help? Am I using the Select node wrong? And how could I properly modularize this whole thing? :-)

Thanks!

I think you need to add Subscribe after where, the reactive for each has it internally, and that the place it actually triggers the subscription (e.g. keeping it in state)

1 Like

Also, you shouldn’t place the stateless observable nodes on update, because they will create a new observable in every frame then.

If you use the stateless ones, they need to be in a cache region or on create…

And yes, they will only work if you have at least one subscriber somewhere. A node from the reactive category or HoldLatest etc.

1 Like

Thanks for the suggestions guys!

Stuff is indeed on Create, and adding a HoldLatest at the very end of the chain works, yeepee!