-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from blueflag/feature/multi-hocks
Create MultiHock factories
- Loading branch information
Showing
9 changed files
with
122 additions
and
7 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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//@flow | ||
import EntityMutationHockFactory from './EntityMutationHockFactory'; | ||
import {createAllRequestAction} from './EntityApi'; | ||
import type {SelectOptions} from './definitions'; | ||
import type {SideEffect} from './definitions'; | ||
|
||
/** | ||
* | ||
* @param {function} sideEffect | ||
* @returns {EntityMutationHock} | ||
* @memberof module:Factories | ||
*/ | ||
export default function MultiMutationHockFactory(sideEffectList: Array<SideEffect>, selectOptions?: SelectOptions): Function { | ||
const actionPrefix = 'ENTITY'; | ||
const FETCH = `${actionPrefix}_FETCH`; | ||
const RECEIVE = `${actionPrefix}_RECEIVE`; | ||
const ERROR = `${actionPrefix}_ERROR`; | ||
|
||
return EntityMutationHockFactory(createAllRequestAction(FETCH, RECEIVE, ERROR, sideEffectList), selectOptions); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@flow | ||
import EntityQueryHockFactory from './EntityQueryHockFactory'; | ||
import {createAllRequestAction} from './EntityApi'; | ||
import type {SelectOptions} from './definitions'; | ||
import type {SideEffect} from './definitions'; | ||
|
||
|
||
/** | ||
* | ||
* @param {function} sideEffect | ||
* @returns {EntityQueryHock} | ||
* @memberof module:Factories | ||
*/ | ||
export default function MultiQueryHockFactory(sideEffectList: Array<SideEffect>, selectOptions?: SelectOptions): Function { | ||
const actionPrefix = 'ENTITY'; | ||
const FETCH = `${actionPrefix}_FETCH`; | ||
const RECEIVE = `${actionPrefix}_RECEIVE`; | ||
const ERROR = `${actionPrefix}_ERROR`; | ||
|
||
return EntityQueryHockFactory(createAllRequestAction(FETCH, RECEIVE, ERROR, sideEffectList), selectOptions); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//@flow | ||
import test from 'ava'; | ||
import sinon from 'sinon'; | ||
import MultiMutationHockFactory from '../MultiMutationHockFactory'; | ||
|
||
const RESOLVE = (aa) => Promise.resolve(aa); | ||
const REJECT = (aa) => Promise.reject(aa); | ||
|
||
|
||
test('MultiMutationHockFactory will return a MutationHock', (t: Object) => { | ||
var aa = async () => ({aa: 'aa'}); | ||
var bb = async () => ({bb: 'bb'}); | ||
|
||
t.is(MultiMutationHockFactory([aa,bb]).name, 'EntityMutationHock'); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//@flow | ||
import test from 'ava'; | ||
import sinon from 'sinon'; | ||
import MultiQueryHockFactory from '../MultiQueryHockFactory'; | ||
|
||
const RESOLVE = (aa) => Promise.resolve(aa); | ||
const REJECT = (aa) => Promise.reject(aa); | ||
|
||
|
||
test('MultiQueryHockFactory will return a QueryHock', (t: Object) => { | ||
var aa = async () => ({aa: 'aa'}); | ||
var bb = async () => ({bb: 'bb'}); | ||
|
||
t.is(MultiQueryHockFactory([aa,bb]).name, 'EntityQueryHock'); | ||
}); |
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