-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
you now need to use the function fx(newState, Effects) from the package to retu BREAKING CHANGE: no more _fx field, now use fx function
- Loading branch information
1 parent
949086b
commit e9dff24
Showing
7 changed files
with
169 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,7 @@ | |
"main": "dist/redux-data-fx.umd.js", | ||
"module": "dist/redux-data-fx.es5.js", | ||
"typings": "dist/types/redux-data-fx.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"files": ["dist"], | ||
"author": "Matthieu Béteille <[email protected]>", | ||
"repository": { | ||
"type": "git", | ||
|
@@ -21,15 +19,17 @@ | |
"scripts": { | ||
"lint": "tslint -t codeFrame 'src/**/*.ts' 'test/**/*.ts'", | ||
"prebuild": "rimraf dist", | ||
"build": "tsc && rollup -c rollup.config.ts && rimraf compiled && typedoc --out dist/docs --target es6 --theme minimal src", | ||
"build": | ||
"tsc && rollup -c rollup.config.ts && rimraf compiled && typedoc --out dist/docs --target es6 --theme minimal src", | ||
"start": "tsc -w & rollup -c rollup.config.ts -w", | ||
"test": "jest", | ||
"test:watch": "jest --watch", | ||
"test:prod": "npm run lint && npm run test -- --coverage --no-cache", | ||
"deploy-docs": "ts-node tools/gh-pages-publish", | ||
"report-coverage": "cat ./coverage/lcov.info | coveralls", | ||
"commit": "git-cz", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post", | ||
"semantic-release": | ||
"semantic-release pre && npm publish && semantic-release post", | ||
"semantic-release-prepare": "ts-node tools/semantic-release-prepare", | ||
"precommit": "lint-staged", | ||
"prepush": "npm run test:prod && npm run build", | ||
|
@@ -47,29 +47,23 @@ | |
}, | ||
"validate-commit-msg": { | ||
"types": "conventional-commit-types", | ||
"helpMessage": "Use \"npm run commit\" instead, we use conventional-changelog format :) (https://github.com/commitizen/cz-cli)" | ||
"helpMessage": | ||
"Use \"npm run commit\" instead, we use conventional-changelog format :) (https://github.com/commitizen/cz-cli)" | ||
} | ||
}, | ||
"jest": { | ||
"transform": { | ||
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
}, | ||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js" | ||
], | ||
"coveragePathIgnorePatterns": [ | ||
"/node_modules/", | ||
"/test/" | ||
], | ||
"moduleFileExtensions": ["ts", "tsx", "js"], | ||
"coveragePathIgnorePatterns": ["/node_modules/", "/test/"], | ||
"coverageThreshold": { | ||
"global": { | ||
"branches": 80, | ||
"functions": 80, | ||
"lines": 80, | ||
"statements": 80 | ||
"branches": 60, | ||
"functions": 60, | ||
"lines": 60, | ||
"statements": 60 | ||
} | ||
}, | ||
"collectCoverage": true, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,23 @@ | ||
export interface StateWithFx { | ||
[key: string]: any | ||
newState: any | ||
_fx: { [key: string]: any } | ||
export type Effects = { [key: string]: any } | ||
|
||
export type BatchEffects = [Effects] | ||
|
||
export interface StateWithFx<S> { | ||
state: S | ||
effects: Effects | BatchEffects | ||
} | ||
|
||
export class StateWithFx<S> { | ||
constructor(state: S, effects: Effects) { | ||
this.state = state | ||
this.effects = effects | ||
} | ||
} | ||
|
||
export function hasFX<S>(s: S | StateWithFx<S>): s is StateWithFx<S> { | ||
return s instanceof StateWithFx | ||
} | ||
|
||
export function hasFX(s: any): s is StateWithFx { | ||
return s && typeof s._fx === 'object' && '_fx' in s && 'newState' in s | ||
export function fx<S>(state: S, effects: Effects): StateWithFx<S> { | ||
return new StateWithFx(state, effects) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.