You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -90,21 +90,40 @@ Construct a new reactive function. The *options* argument should have the follow
90
90
91
91
**inputs* - The input properties. An array of **[ReactiveProperty](https://github.com/datavis-tech/reactive-property#constructor)** instances.
92
92
**output* (optional) - The output property. An instance of **[ReactiveProperty](https://github.com/datavis-tech/reactive-property#constructor)**.
93
-
**callback* - The reactive function callback. Arguments are values extracted from *inputs*. The return value will be assigned as the value of *output* during a **[digest](#digest)**.
93
+
**callback* - The reactive function callback. Arguments are values of *inputs*. The return value will be assigned to *output*.
94
94
95
-
This constructor sets up a reactive function such that *callback* be invoked when all properties in *inputs* are defined and whenever they change. The *callback* function will be invoked on the **[nextFrame](#next-frame)** after inputs change.
95
+
This constructor sets up a reactive function such that *callback* be invoked
96
+
97
+
* when all input properties are defined,
98
+
* after any input properties change,
99
+
* during a **[digest](#digest)**.
100
+
101
+
An input property is considered "defined" if it has any value other than `undefined`. The special value `null` is considered to be defined.
102
+
103
+
An input property is considered "changed" when
104
+
105
+
* the reactive function is initially set up, and
106
+
* whenever its value is set.
107
+
108
+
Input properties for one reactive function may also be outputs of another.
Propagates changes from input properties through the data flow graph defined by all reactive properties using [topological sorting](https://en.wikipedia.org/wiki/Topological_sorting).
116
+
Propagates changes from input properties through the data flow graph defined by all reactive properties using [topological sorting](https://en.wikipedia.org/wiki/Topological_sorting). An edge in the data flow graph corresponds to a case where the output of one reactive function is used as an input to another.
117
+
118
+
Whenever any input properties for any reactive function change, **[digest](#digest)** is debounced (scheduled for invocation) on the **[nextFrame](#next-frame)**. Because it is debounced, multiple synchronous changes to input properties collapse into a single digest invocation.
119
+
120
+
Digests are debounced to the next animation frame rather than the next tick because browsers will render the page at most every animation frame (approximately 60 frames per second). This means that if DOM manipulations are triggered by reactive functions, and input properties are changed more frequently than 60 times per second (e.g. mouse or keyboard events), the DOM manipulations will only occur at most 60 times per second, not more than that.
Schedules the given function to execute on the next animation frame or next tick. This is a simple polyfill for `[requestAnimationFrame](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame)` that falls back to `[setTimeout](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout)`. The main reason for having this is for use in the [tests](https://github.com/datavis-tech/reactive-function/blob/master/test.js), which run in a Node.js environment where `requestAnimationFrame` is not available. Automatic digests are debounced against this function.
124
+
Schedules the given function to execute on the next animation frame or next tick.
125
+
126
+
This is a simple polyfill for `[requestAnimationFrame](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame)` that falls back to `[setTimeout](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout)`. The main reason for having this is for use in the [tests](https://github.com/datavis-tech/reactive-function/blob/master/test.js), which run in a Node.js environment where `requestAnimationFrame` is not available. Automatic digests are debounced against this function.
108
127
109
128
## Related Work
110
129
@@ -114,6 +133,8 @@ Schedules the given function to execute on the next animation frame or next tick
0 commit comments