DEV Community

Discussion on: The Quest for ReactiveScript

Collapse
 
ninjin profile image
Jin

It is interesting to see here the destiny operator, in which we have been using component composition description language for a long time.

A few examples of how we declare object methods (channels):

name \Jin
Enter fullscreen mode Exit fullscreen mode

This is a method that returns a constant string (one way channel).

name?val \Jin
Enter fullscreen mode Exit fullscreen mode

This is the same, but the meaning can be changed (singal in your terminology and two-way channel in ours).

Now the operator of destiny:

greeting /
    \Mr.
    <= name
Enter fullscreen mode Exit fullscreen mode

There is already a derived method that returns an array from a constant string and the values of another method.

And now, the most interesting thing is the bidirectional channel:

title?val <=> name?val
Enter fullscreen mode Exit fullscreen mode

We can read and write in 'title' without even knowing that we are actually working with 'name'.

And then there is the reverse destiny operator:

name => title
Enter fullscreen mode Exit fullscreen mode

It may seem that this is the same as the normal destiny operator, but it matters when linking components to each other:

sub /
    <= Input $mol_string
        value => name
    <= Output $mol_paragraph
        title <= name
Enter fullscreen mode Exit fullscreen mode

Now the Output directly uses the value from the Input, and we control it through the "name" channel.

And yes, Input and Output is channels too which returns cached instance of other components.

Here you can see the generated TS code.