@thi.ng/wasm-api-schedule 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/README.md +10 -6
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -22,7 +22,8 @@ This project is part of the
|
|
|
22
22
|
|
|
23
23
|
Delayed & scheduled function execution (via setTimeout() etc.) for hybrid WASM apps. This is a support package for [@thi.ng/wasm-api](https://github.com/thi-ng/umbrella/tree/develop/packages/wasm-api).
|
|
24
24
|
|
|
25
|
-
The package provides a WASM bridge API and abstraction for scheduling function
|
|
25
|
+
The package provides a WASM bridge API and abstraction for scheduling function
|
|
26
|
+
calls via:
|
|
26
27
|
|
|
27
28
|
- **once**: `setTimeout()` / `clearTimeout()`
|
|
28
29
|
- **interval**: `setInterval()` / `clearInterval()`
|
|
@@ -47,8 +48,8 @@ try schedule.init(customAllocator);
|
|
|
47
48
|
// user callback function
|
|
48
49
|
fn exampleCallback(raw: ?*anyopaque) void {
|
|
49
50
|
if (wasm.ptrCast(*u32, raw)) |state| {
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
// do something ...
|
|
52
|
+
}
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
// arbitrary user state
|
|
@@ -57,17 +58,20 @@ var state: u32 = 0xdecafbad;
|
|
|
57
58
|
// schedule a single/one-off callback 500ms in the future
|
|
58
59
|
const listenerID = try schedule.schedule(
|
|
59
60
|
.once,
|
|
60
|
-
&.{ .callback = exampleCallback, .ctx = &state },
|
|
61
61
|
500,
|
|
62
|
+
exampleCallback,
|
|
63
|
+
&state,
|
|
62
64
|
);
|
|
63
65
|
|
|
64
66
|
// ...or maybe cancel it again
|
|
65
67
|
schedule.cancel(listenerID);
|
|
66
68
|
```
|
|
67
69
|
|
|
68
|
-
Also see
|
|
70
|
+
Also see the
|
|
69
71
|
[zig-counter](https://github.com/thi-ng/umbrella/blob/develop/examples/zig-counter/)
|
|
70
|
-
|
|
72
|
+
and
|
|
73
|
+
[zig-todo-list](https://github.com/thi-ng/umbrella/blob/develop/examples/zig-todo-list/)
|
|
74
|
+
example projects for more advanced usage...
|
|
71
75
|
|
|
72
76
|
## Status
|
|
73
77
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/wasm-api-schedule",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Delayed & scheduled function execution (via setTimeout() etc.) for hybrid WASM apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@thi.ng/api": "^8.4.6",
|
|
39
|
-
"@thi.ng/wasm-api": "^1.0.
|
|
40
|
-
"@thi.ng/wasm-api-bindgen": "^0.
|
|
39
|
+
"@thi.ng/wasm-api": "^1.0.1",
|
|
40
|
+
"@thi.ng/wasm-api-bindgen": "^0.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@microsoft/api-extractor": "^7.33.5",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"status": "alpha",
|
|
93
93
|
"year": 2022
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "8d59e559a576ecb3d2c2d13edf5c3146df95d6ac\n"
|
|
96
96
|
}
|