haskellfrpreactive-banana

Getting updates from accumB without delay


THe documentation for accumB says:

Note: As with stepper, the value of the behavior changes "slightly after" the events occur. This allows for recursive definitions.

In my case there is no recursion, but i want to get updates "right now", not "slightly after". Why there is no special version of accumB? I guess, i'm missing something obvious?


EDIT: In my application I have data Config, which holds various configuration values and a bunch of Event (Config -> Config), which are fired when user changes some value in GUI. Now, i want other parts of my program to access Config whenever they want, that's why i used Behavior Config there. The problem is that when changing event is fired, the behavior still has old value of Config, so i can't observe this change immediately.


Solution

  • If you have a Behavior Conf, then you can make other Behaviors from it via the Applicative class combinators. For instance, it may be that you turn it into a Behavior String which is then displayed in a text field. Once you feed a Behavior to such an UI widget, the widget code makes sure that the new value of the Behavior is displayed.

    If you need an explicit indication of when the configuration has changed, then an Event Conf may be more appropriate. You can use the accumE function for that, it will contain the new value.