Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit b7da185

Browse files
committed
Improved types for effects.js and union.js.
1 parent 20211f8 commit b7da185

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# composi/core Changelog
22

3+
## 2.5.6 (October 26, 2019)
4+
5+
### src/effects.js, src/union.js
6+
7+
* Improved types for both effects.js and union.js.
8+
9+
## 2.5.5 (October 25, 2019)
10+
11+
* Removed `jsconfig.json` and replaced with `tsconfig.json`. The tsconfig has type check options. This removes need for NPM script test `checkjs` to use options, simplifying it to just `"checkjs": "tsc"`.
12+
313
## 2.5.4 (October 25, 2019)
414

515
### src/runtime.js

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@composi/core",
3-
"version": "2.5.5",
3+
"version": "2.5.6",
44
"description": "A JavaScript library for creating websites, PWAs and hybrid apps.",
55
"main": "src/index.js",
66
"module": "dist/composi-core.mjs",

src/effects.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
/**
2+
* @typedef {import('./runtime').Send} Send
3+
* @typedef {import('./runtime').Message} Message
4+
* @typedef {Object} State
5+
* @typedef {() => State} GetState
6+
* @typedef {(getState: GetState, send: Send) => any} Effect
7+
*/
18
/**
29
* Function to batch effects together.
3-
* @param {...Function} effects
4-
* @return {Function} Function
10+
* @param {...Effect} effects
11+
* @return {(getState: GetState, send: Send) => any} Function
512
*/
6-
export const batchEffects = (...effects) => (state, send) =>
7-
effects.map(effect => effect && effect(state, send))
13+
export const batchEffects = (...effects) => (getState, send) =>
14+
effects.map(effect => effect && effect(getState, send))
15+

src/union.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@ function createUnion(types) {
3434
return { variants, match }
3535
}
3636

37+
/**
38+
* @typedef {Object} MessageUnion
39+
*/
40+
3741
/**
3842
* Create a union of types for matching up with functions. This is used to define actions for the `update` method of a runtime program.
3943
* @param {...string} types
44+
* @returns {MessageUnion} MessagesUnion
4045
*/
4146
export function union(...types) {
4247
const { variants, match } = createUnion(types)

0 commit comments

Comments
 (0)