@davidcal/frosth 1.3.0 → 1.5.0

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Frosth - Yet another UI framework
2
2
 
3
- **Latest version**: v1.3.0
3
+ **Latest version**: v1.5.0
4
4
 
5
5
  ## Motivation
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@davidcal/frosth",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Async-first CRUD-last UI framework that treats encapsulation as a solved problem.",
5
5
  "type": "module",
6
6
  "main": "./src/sigew.js",
@@ -1,3 +1,5 @@
1
+ import { create_signal } from "./create_signal.js";
2
+
1
3
  /**
2
4
  * A beacon is a valueless-sink. The output is a stable interface as provided on creation. Subscribers are notified whenever the beacon is fired.
3
5
  */
@@ -106,7 +106,7 @@ class Self {
106
106
  this._parent._children.delete(this);
107
107
  }
108
108
 
109
- for (const handle_dispose of this._dispose_handlers) {
109
+ for (const handle_dispose of this._dispose_handlers.toReversed()) {
110
110
  handle_dispose();
111
111
  }
112
112
  }
@@ -0,0 +1,50 @@
1
+ import { create_beacon } from "./create_beacon.js";
2
+
3
+ export const create_stream = () => {
4
+ // activity: content-agnostic term for a payload in a stream, whether that be an event or an action.
5
+ let activity_seq = 0;
6
+
7
+ let outstanding_activities = [];
8
+
9
+ const drain = () => {
10
+ const activities = outstanding_activities;
11
+
12
+ outstanding_activities = [];
13
+
14
+ return activities;
15
+ };
16
+
17
+ const reader = {
18
+ drain,
19
+ };
20
+
21
+ const beacon = create_beacon(reader);
22
+
23
+ const result = (s) => beacon(s);
24
+
25
+ result.emit = (body) => {
26
+ const activity = {
27
+ seq: activity_seq++,
28
+ body,
29
+ };
30
+
31
+ outstanding_activities.push(activity);
32
+
33
+ beacon.fire();
34
+ };
35
+
36
+ result.emit_many = (bodies) => {
37
+ for (const body of bodies) {
38
+ const activity = {
39
+ seq: activity_seq++,
40
+ body,
41
+ };
42
+
43
+ outstanding_activities.push(activity);
44
+ }
45
+
46
+ beacon.fire();
47
+ };
48
+
49
+ return result;
50
+ };
package/src/sigew.js CHANGED
@@ -7,12 +7,14 @@ import { render } from "./render.js";
7
7
  import { MARK_INSTALLABLE } from "./constants.js";
8
8
  import { create_memo } from "./create_memo.js";
9
9
  import { create_beacon } from "./create_beacon.js";
10
+ import { create_stream } from "./create_stream.js";
10
11
 
11
12
  export { create_self };
12
13
  export { create_signal };
13
14
  export { h };
14
15
  export { create_memo };
15
16
  export { create_beacon };
17
+ export { create_stream };
16
18
 
17
19
  export const installarea = (s) => {
18
20
  const storage = s.create_housed_signal(() => undefined);