Skip to content

More specific definitions#41

Merged
afitiskin merged 2 commits intoafitiskin:masterfrom
brainbeanapps:more_specific_defs
May 10, 2018
Merged

More specific definitions#41
afitiskin merged 2 commits intoafitiskin:masterfrom
brainbeanapps:more_specific_defs

Conversation

@alexey-pelykh
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread src/index.d.ts
fulfill: RoutineActionCreator<any>;
export interface RoutineActionCreators<TActionCreator> {
trigger: TActionCreator;
request: ActionFunctionAny<Action<any>>;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To support payload / meta creators that may be passed as createRoutine('TYPE', payloadCreator, metaCreator) in non-trigger actions. RoutineActionCreator limited metaCreator to be only (payload?: any) while it can be (...args: any[]) to handle myRoutine(payload, some, thing)

Comment thread src/index.d.ts
failure: RoutineActionCreator<any>;
fulfill: RoutineActionCreator<any>;
export interface RoutineActionCreators<TActionCreator> {
trigger: TActionCreator;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trigger action creator is strongly-typed if called as myRoutine(typedPayload), so it should be consistent with myRoutine.trigger(typedPayload)

Comment thread src/index.d.ts
export function createRoutine(
typePrefix: string
): Routine<ActionFunction0<RoutineAction<void>>>;
): Routine<ActionFunctionAny<Action<any>>>;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since createRoutine calls createAction, a createAction implementation (not definition until DefinitelyTyped/DefinitelyTyped#25286) supports mySimpleAction(), mySimpleAction(payload), and mySimpleAction(payload, nothing, interesting, unless, payloadIsError) for const mySimpleAction = createAction('SIMPLE_ACTION'), thus createRoutine() returning a trigger should behave the same

@afitiskin
Copy link
Copy Markdown
Owner

afitiskin commented May 8, 2018

Is everything ready for merge?

@alexey-pelykh
Copy link
Copy Markdown
Contributor Author

@afitiskin it is now, please check the last commit

@afitiskin afitiskin merged commit 22c0906 into afitiskin:master May 10, 2018
@alexey-pelykh alexey-pelykh deleted the more_specific_defs branch May 10, 2018 08:27
LKay added a commit to LKay/redux-saga-routines that referenced this pull request May 11, 2018
Comment thread src/index.d.ts
props: P
}

export function bindRoutineToReduxForm<Payload extends ReduxFormPayload<FormData, P>>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FormData here refers to global FormData object which is totally unrelated to redux-form's type.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, somehow I've lost part of the PR - #45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants