Discussion:
[lively-kernel] request for info about some "spec" parameters of connections
Davide Della Casa
2014-09-16 15:33:53 UTC
Permalink
Looking at this, spec for connections:

+ 'spec can be: {\n'
+ ' removeAfterUpdate: Boolean,\n'
+ ' forceAttributeConnection: Boolean,\n'
+ ' converter: Function,\n'
+ ' updater: Function,\n'
+ ' varMapping: Object\n'
+ '}',

converter and updater are explained in a couple of docs, that’s cool.

Any insight/organic explanation about what the others (removeAfterUpdate, forceAttributeConnection, varMapping) do and in which context they are necessary/useful? Online somewhere, papers anywhere, previous email threads?

If not, can anybody give a sketch in this thread?

Cheers!
Davide Della Casa
Marko Röder
2014-09-16 17:26:26 UTC
Permalink
Hi Davide -

Those attributes work as follows:

removeAfterUpdate: If you set this to true, the connection will be removed after it was called one time (one-time connection).
forceAttributeConnection: If this is set to true, executing a method that is the connection source will not trigger the target to update but changing the source attribute to a different value/function will (example: see lively.bindings.tests.BindingTests.ConnectionTest -> test42ForceAttributeConnection and play with the forceAttributeConnection flag).
varMapping: Additional variables/values you want to have access to in the updater and converter function. Usually, there is "source" and "target" mapped into the scope of those functions.

Some things may be hard to discover within the code but everything is open and accessible ;-). A lot of the times, test cases also help with APIs and features.

I hope this helps,

- Marko
Post by Davide Della Casa
+ 'spec can be: {\n'
+ ' removeAfterUpdate: Boolean,\n'
+ ' forceAttributeConnection: Boolean,\n'
+ ' converter: Function,\n'
+ ' updater: Function,\n'
+ ' varMapping: Object\n'
+ '}',
converter and updater are explained in a couple of docs, that’s cool.
Any insight/organic explanation about what the others (removeAfterUpdate, forceAttributeConnection, varMapping) do and in which context they are necessary/useful? Online somewhere, papers anywhere, previous email threads?
If not, can anybody give a sketch in this thread?
Cheers!
Davide Della Casa
_______________________________________________
lively-kernel mailing list
http://lists.hpi.uni-potsdam.de/listinfo/lively-kernel
Robert Krahn
2014-09-16 18:23:07 UTC
Permalink
The varMapping aspect might need some explanation: With plain JS it is not
possible to capture the internal state of functions (closures, closed
values). The data bindings, as well as scripts you attach to objects,
however, should be serializable. This means we need to capture this state
somehow. When you want converters / updaters / scripts to be real closures
you can use the "varMapping" option to pass in values from the outside. The
underlaying mechanism is implemented in the lively.Closure
class: $world.browseCode("lively.Closure", null, "lively.lang.Closure");
Post by Davide Della Casa
+ 'spec can be: {\n'
+ ' removeAfterUpdate: Boolean,\n'
+ ' forceAttributeConnection: Boolean,\n'
+ ' converter: Function,\n'
+ ' updater: Function,\n'
+ ' varMapping: Object\n'
+ '}',
converter and updater are explained in a couple of docs, that’s cool.
Any insight/organic explanation about what the others (removeAfterUpdate,
forceAttributeConnection, varMapping) do and in which context they are
necessary/useful? Online somewhere, papers anywhere, previous email threads?
If not, can anybody give a sketch in this thread?
Cheers!
Davide Della Casa
_______________________________________________
lively-kernel mailing list
http://lists.hpi.uni-potsdam.de/listinfo/lively-kernel
Loading...