forked from birdiecare/galette
-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.ts
39 lines (30 loc) · 1.18 KB
/
actions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { Action } from "redux";
import { typedActionCreatorFactory } from '@galette/core';
import { ReportActionOptions } from "./types";
import { randomIdentifier } from "./functions";
export type ReportErrorAction = Action & {
error: Error;
identifier: string;
options?: ReportActionOptions;
}
type ReportErrorActionCreator = (error: Error, options?: ReportActionOptions, identifier?: string) => ReportErrorAction;
export type ReportErrorActionCreatorWithType = ReportErrorActionCreator & { type: string };
export type DismissErrorAction = Action & {
identifier: string;
}
type DismissErrorActionCreator = (identifier: string) => DismissErrorAction;
export type DismissErrorActionCreatorWithType = DismissErrorActionCreator & { type: string };
export const reportError : ReportErrorActionCreatorWithType = typedActionCreatorFactory(
'@Galette/REPORT_ERROR',
(error: Error, options?: ReportActionOptions, identifier?: string) => ({
error,
options,
identifier: identifier || randomIdentifier(),
})
);
export const dismissError : DismissErrorActionCreatorWithType = typedActionCreatorFactory(
'@Galette/DISMISS_ERROR',
(identifier: string) => ({
identifier,
})
);