Question

Can be Flash looked like a Reactive application?

For example http://elm-lang.org/ Elm language is Reactive, with Flash we may create the same applications as in Elm, but not in functional way, so is it reactive or not?

Was it helpful?

Solution

While I have not used Flash, I can tell you what Reactive Programming is (also called Dataflow Programming). Let's say we have two equations:

c = a + b
d = c + e

If we start with a = 1, b = 2 and e = 3 then initially the value of 'c' is 1+2=3 and 'd' is 3+3=6. If the value of 'a' is later changed to 10 then the new value of 'c' is 10+2=12 and 'd' is 12+3=15.

Where reactive programming comes into the mix is that value of 'd' is automatically updated when the value of 'c' or 'e' is changed. All dataflow variables act this way throughout the whole program so you never have to worry about having old values. You might see a similarity with dataflow and spreadsheets. The value of a dataflow variable is the value of it at this moment, not some past time.

Dataflow variables "react" to changing data.

Another example would be setting a variable to the current time. Every time you access that variable it will return the current time, not the time it was first set.

All of this happens without the programmer explicitly updating the value of the variable, the dataflow system handles the updating.

A note on terminology... "Reactive Programming" is just the modern term for "Dataflow Programming" but they both are the same thing. You may have an easier time using "dataflow" as a search term.

OTHER TIPS

Based off my understanding of reactive programming from skimming over the Wiki article about it;

For example, in an imperative programming setting, a := b + c would mean that a is being assigned the result of b + c in the instant the expression is evaluated. Later, the values of b and c can be changed with no effect on the value of a.

In reactive programming, the value of a would be automatically updated based on the new values.

ActionScript 3 can be considered 'reactive' by implementing getters and setters, e.g.

public class Main
{
    public var b:int = 1;
    public var c:int = 1;

    public function get a():int
    {
        return b + c;
    }
}

Where the value a would differ depending on b and c.

var main:Main = new Main();
trace(main.a); // 2

main.b = 5;
trace(main.a); // 6
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top