Skip to content

Commit

Permalink
Merge 02beb30 into da0c9c1
Browse files Browse the repository at this point in the history
  • Loading branch information
unional committed Apr 30, 2018
2 parents da0c9c1 + 02beb30 commit f7593c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/createEvent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ test('empty eventCreator creates FSA compliant action', t => {
t.true(isFSA(blip(undefined, undefined)))
})

test('Payload type defaults to any', t => {
const nopayload = createEvent('noPayload')
t.true(isFSA(nopayload({ a: 1 }, undefined)))
})

test('eventCreator with payload creates FSA compliant action', t => {
const count = createEvent<number>('count')
t.true(isFSA(count(1, undefined)))
Expand Down
2 changes: 1 addition & 1 deletion src/createEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function createScopedCreateEvent(scope: string): typeof createEvent {
return (type) => createEvent(`${scope}/${type}`)
}

export function createEvent<Payload = undefined, Meta = undefined>(type: string, isError: ((payload: Payload) => boolean) | boolean = defaultIsErrorPredicate): Event<Payload, Meta> {
export function createEvent<Payload = any, Meta = undefined>(type: string, isError: ((payload: Payload) => boolean) | boolean = defaultIsErrorPredicate): Event<Payload, Meta> {
return Object.assign(
(payload: Payload, meta: Meta) => {
return isError && (typeof isError === 'boolean' || isError(payload)) ?
Expand Down

0 comments on commit f7593c0

Please sign in to comment.