Typescript utilities for easier typing in redux (observable).
npm install safetypingsTypescript utilities for easier typing in redux (observable).
Aggregated from typesafe-actions.
Useful utility type that will infer action types from _action creator map_, e.g.
``ts
// types.d.ts
import { ActionType } from 'safetypings';
import * as actions from './actions';
export type RootAction = ActionType
`
> It only extracts types that are _action creators_.
Check if passed action is equal given action type, e.g.
`ts
import { RootAction, RootState, Services } from 'MyTypes';
import { Epic } from 'redux-observable';
import { filter } from 'rxjs/operators';
import { isOfType } from 'safetypings';
import * as actions from './actions';
export const loginEpic: Epic
action$,
state$,
{ ajax },
) =>
action$.pipe(
filter(isOfType(actions.LOGIN)),
// value type is now narrowed to { type: 'LOGIN', payload: { username: string } }`
);
Check if value passed is present (non-nullable), e.g.
`ts``
action$.pipe(
// ...
map(getAccessToken),
filter(isPresent),
// removes null and undefined from value type
);