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
Copy file name to clipboardExpand all lines: README.md
+21-8Lines changed: 21 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,10 @@ npm install skatejs-dom-diff
14
14
15
15
## Usage
16
16
17
+
Where `options` are accepted, you may provide:
18
+
19
+
-`done` If specified, diffing is performed in a web worker and this callback is called when it's done.
20
+
17
21
### `diff(source, target, options)`
18
22
19
23
Diffs two virtual trees.
@@ -264,43 +268,52 @@ const {
264
268
265
269
You can tell the differ to do its work in a web worker simply by passing a `done` callback option to any of the three major entry functions (`diff()`, `merge()`, `render()`).
266
270
267
-
#### `diff()`
271
+
#### `diff(source, target, options)`
268
272
269
273
In the case of `diff()`, it's called once the diffing algorithm has finished in the worker and passed the `instructions`. The patch `instructions` are the only argument passed into the callback.
270
274
271
275
```js
276
+
/** @jsx h */
277
+
import { h, diff } from'skatejs-dom-diff';
278
+
272
279
functiondone (instructions) {
273
280
patch(instructions);
274
281
}
275
-
diff({ source, destination, done });
282
+
diff(<p>source</p>, <p>target</p>, { done });
276
283
```
277
284
278
-
#### `merge()`
285
+
#### `merge(source, target, options)`
279
286
280
287
For `done()`, it's passed in the same exact way. The only difference is that it's called after the patch is performed but it's still passed the instructions that were performed by the patch algorithm.
281
288
282
289
```js
290
+
/** @jsx h */
291
+
import { h, merge } from'skatejs-dom-diff';
292
+
283
293
functiondone (instructions) {
284
294
// The DOM has been updated, do what you want here.
285
295
}
286
-
merge({ source, destination, done });
296
+
merge(<p>source</p>, <p>target</p>, { done });
287
297
```
288
298
289
-
#### `render()`
299
+
#### `render(source, target, options)`
290
300
291
301
And for `render()`, it is the same as the `merge()` function. So once the vDOM is rendered and DOM is patched, `done()` is called with the instructions that were performed.
0 commit comments