lahama 3.0.0 → 4.0.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.
Files changed (2) hide show
  1. package/dist/lahama.js +29 -0
  2. package/package.json +1 -1
package/dist/lahama.js CHANGED
@@ -120,6 +120,33 @@ function extractPropsAndEvents(vdom) {
120
120
  return { props, events }
121
121
  }
122
122
 
123
+ let isScheduled = false;
124
+ const jobs = [];
125
+ function enqueueJob(job) {
126
+ jobs.push(job);
127
+ scheduleUpdate();
128
+ }
129
+ function scheduleUpdate() {
130
+ if (isScheduled) return
131
+ isScheduled = true;
132
+ queueMicrotask(processJobs);
133
+ }
134
+ function processJobs() {
135
+ while (jobs.length > 0) {
136
+ const job = jobs.shift();
137
+ const result = job();
138
+ Promise.resolve(result).then(
139
+ () => {
140
+ },
141
+ (error) => {
142
+ console.error(`[scheduler]: ${error}`);
143
+ }
144
+ );
145
+ job();
146
+ }
147
+ isScheduled = false;
148
+ }
149
+
123
150
  function mountDom(
124
151
  vdom,
125
152
  parentEl,
@@ -141,6 +168,7 @@ function mountDom(
141
168
  }
142
169
  case DOM_TYPES.COMPONENT : {
143
170
  createComponentNode(vdom, parentEl, index, hostComponent);
171
+ enqueueJob(() => vdom.component.onMounted());
144
172
  break
145
173
  }
146
174
  default : {
@@ -215,6 +243,7 @@ function destroyDom(vdom) {
215
243
  }
216
244
  case DOM_TYPES.COMPONENT : {
217
245
  vdom.component.unmount();
246
+ enqueueJob(() => vdom.component.onUnMounted());
218
247
  break
219
248
  }
220
249
  default : {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lahama",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "",
5
5
  "main": "dist/lahama.js",
6
6
  "files": [