Comparing version 0.8.3 to 0.8.4
@@ -15,3 +15,6 @@ import { async as subject } from 'most-subject'; | ||
var using = never; | ||
var using = getWarn({ | ||
domainName, | ||
name | ||
}); | ||
@@ -140,3 +143,6 @@ function use(thunk) { | ||
function never(props) { | ||
var getWarn = ({ | ||
domainName, | ||
name | ||
}) => function never(props) { | ||
console.warn(` | ||
@@ -147,5 +153,13 @@ | ||
`, props); | ||
Name: | ||
${name} | ||
Domain: | ||
${domainName} | ||
Arguments: | ||
${props} | ||
`); | ||
return new Promise(() => {}); | ||
} | ||
}; | ||
//# sourceMappingURL=effect.js.map |
// import {type Subject, async as subject} from 'most-subject' | ||
function isAction(data) { | ||
return typeof data === 'object' && data != null && typeof data.type === 'string'; | ||
} | ||
export function safeDispatch(data, dispatch) { | ||
if (typeof data === 'object' && data != null && typeof data.type === 'string') { | ||
dispatch(data); | ||
} | ||
if (Array.isArray(data)) return data.filter(isAction).forEach(action => dispatch(action)); | ||
if (isAction(data)) return dispatch(data); | ||
return; | ||
} | ||
@@ -7,0 +11,0 @@ export function port(dispatch, state$, action$) { |
@@ -27,3 +27,6 @@ "use strict"; | ||
var using = never; | ||
var using = getWarn({ | ||
domainName, | ||
name | ||
}); | ||
@@ -152,3 +155,6 @@ function use(thunk) { | ||
function never(props) { | ||
var getWarn = ({ | ||
domainName, | ||
name | ||
}) => function never(props) { | ||
console.warn(` | ||
@@ -159,5 +165,13 @@ | ||
`, props); | ||
Name: | ||
${name} | ||
Domain: | ||
${domainName} | ||
Arguments: | ||
${props} | ||
`); | ||
return new Promise(() => {}); | ||
} | ||
}; | ||
//# sourceMappingURL=effect.js.map |
@@ -10,6 +10,10 @@ "use strict"; | ||
// import {type Subject, async as subject} from 'most-subject' | ||
function isAction(data) { | ||
return typeof data === 'object' && data != null && typeof data.type === 'string'; | ||
} | ||
function safeDispatch(data, dispatch) { | ||
if (typeof data === 'object' && data != null && typeof data.type === 'string') { | ||
dispatch(data); | ||
} | ||
if (Array.isArray(data)) return data.filter(isAction).forEach(action => dispatch(action)); | ||
if (isAction(data)) return dispatch(data); | ||
return; | ||
} | ||
@@ -16,0 +20,0 @@ |
{ | ||
"name": "effector", | ||
"version": "0.8.3", | ||
"version": "0.8.4", | ||
"description": "Redux effects", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -29,3 +29,3 @@ //@flow | ||
// handlers.add((payload, state) => state$.next(state)) | ||
let using: (params: Params) => Promise<Done> = never | ||
let using: (params: Params) => Promise<Done> = getWarn({domainName, name}) | ||
function use(thunk: (params: Params) => Promise<Done>) { | ||
@@ -162,3 +162,3 @@ using = thunk | ||
function never(props: any): Promise<any> { | ||
const getWarn = ({domainName, name}) => function never(props: any): Promise<any> { | ||
console.warn(` | ||
@@ -169,4 +169,12 @@ | ||
`, props) | ||
Name: | ||
${name} | ||
Domain: | ||
${domainName} | ||
Arguments: | ||
${props} | ||
`) | ||
return new Promise(() => {}) | ||
} |
@@ -6,2 +6,10 @@ //@flow | ||
function isAction(data): boolean %checks { | ||
return ( | ||
typeof data === 'object' | ||
&& data != null | ||
&& typeof data.type === 'string' | ||
) | ||
} | ||
export function safeDispatch<R>( | ||
@@ -11,9 +19,5 @@ data: R, | ||
) { | ||
if ( | ||
typeof data === 'object' | ||
&& data != null | ||
&& typeof data.type === 'string' | ||
) { | ||
dispatch(data) | ||
} | ||
if (Array.isArray(data)) return data.filter(isAction).forEach(action => dispatch(action)) | ||
if (isAction(data)) return dispatch(data) | ||
return | ||
} | ||
@@ -20,0 +24,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
207554
2173