Manually changing the value of a behaviour

51 views
Skip to first unread message

Thomas Wessel

unread,
Nov 30, 2012, 12:45:44 PM11/30/12
to fla...@googlegroups.com
I am very new to this, so bear with me. I would like to create a behaviour, that event listeners (as in good old js) can assign an integer to. This update should then propagate to the dependent behaviors.

Smth like:

x = Behavior();
x.setValue(1);
y = x + 2;
function listener() {
  x.setValue(3); // y = 5
}

I have been reading the tutorial but somehow I could not find a way of just "manually" changing the value of a behavior.

Thanks :)

Leo Meyerovich

unread,
Nov 30, 2012, 2:09:14 PM11/30/12
to fla...@googlegroups.com
Hi Thomas,

You can create an empty event stream with receiverE() and then ".sendEvent(v)" to it:

var ticksE = receiverE();
setInterval(function () { ticksE.sendEvent("tick"); }, 1000); // ticksE is now a stream of "tick" values

Regards,

- Leo
> --
> Flapjax home page: www.flapjax-lang.org
> Flapjax list: groups.google.com/group/flapjax
> Post: fla...@googlegroups.com
> Unsubscribe: flapjax-u...@googlegroups.com

Thomas Larsen Wessel

unread,
Dec 10, 2012, 7:29:49 AM12/10/12
to fla...@googlegroups.com
I just realized that I never answered to you. Thanks for your help, it helped me get where I wanted to :)
Reply all
Reply to author
Forward
0 new messages