@soundworks/core 4.0.0-alpha.10 → 4.0.0-alpha.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soundworks/core",
3
- "version": "4.0.0-alpha.10",
3
+ "version": "4.0.0-alpha.12",
4
4
  "description": "Open-source creative coding framework for distributed applications based on Web technologies",
5
5
  "authors": [
6
6
  "Benjamin Matuszewski",
@@ -75,6 +75,18 @@ class BaseSharedStateCollection {
75
75
  return this._states.map(state => state.get(name));
76
76
  }
77
77
 
78
+ /**
79
+ * Update all states of the collection with given values.
80
+ * @param {object} updates - key / value pairs of updates to apply to the state.
81
+ * @param {mixed} [context=null] - optionnal contextual object that will be propagated
82
+ * alongside the updates of the state. The context is valid only for the
83
+ * current call and will be passed as third argument to all update listeners.
84
+ */
85
+ async set(updates, context = null) {
86
+ const promises = this._states.map(state => state.set(updates, context));
87
+ return Promise.all(promises);
88
+ }
89
+
78
90
  /**
79
91
  * Subscribe to any state update of the collection.
80
92
  *
@@ -174,6 +186,22 @@ class BaseSharedStateCollection {
174
186
  find(func) {
175
187
  return this._states.find(func);
176
188
  }
189
+
190
+ /**
191
+ * Iterable API for use in `for .. of` loops
192
+ */
193
+ [Symbol.iterator]() {
194
+ let index = 0;
195
+
196
+ return {
197
+ next: () => {
198
+ const value = this._states[index++];
199
+ const done = index >= this._states.length;
200
+
201
+ return { value, done };
202
+ }
203
+ }
204
+ }
177
205
  }
178
206
 
179
207
  export default BaseSharedStateCollection;
@@ -1,31 +0,0 @@
1
- name: GH Pages
2
-
3
- on:
4
- push:
5
- tags:
6
- - '*'
7
-
8
- permissions:
9
- contents: write
10
-
11
- jobs:
12
- deploy:
13
- runs-on: ubuntu-latest
14
- steps:
15
- - name: Checkout code
16
- uses: actions/checkout@v3
17
-
18
- - name: 'Install Node'
19
- uses: actions/setup-node@v3.6.0
20
-
21
- - name: Install dependencies
22
- run: npm install
23
-
24
- - name: Build Docs
25
- run: npm run doc
26
-
27
- - name: Deploy
28
- uses: JamesIves/github-pages-deploy-action@v4
29
- with:
30
- folder: docs
31
-
@@ -1,18 +0,0 @@
1
- name: Unit Tests
2
- on: push
3
-
4
- jobs:
5
- test:
6
- runs-on: ubuntu-latest
7
- steps:
8
- - name: Checkout
9
- uses: actions/checkout@v3
10
-
11
- - name: 'Install Node'
12
- uses: actions/setup-node@v3.6.0
13
-
14
- - name: Install dependencies
15
- run: npm install
16
-
17
- - name: "Run Test"
18
- run: npm test -- tests/**.spec.js