@equinor/fusion-observable
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -17,20 +17,5 @@ export function createAction(type, prepareAction) { | ||
} | ||
export function createAsyncAction(type, request, success, failure) { | ||
const action = createAction(type, request); | ||
if (success) { | ||
Object.assign(action, { | ||
success: createAction([type, 'success'].join('::'), success), | ||
}); | ||
} | ||
if (failure) { | ||
Object.assign(action, { | ||
success: createAction([type, 'failure'].join('::'), failure), | ||
}); | ||
} | ||
return action; | ||
} | ||
export const isSuccessAction = (action) => !!action.type.match(/::success$/); | ||
export const isFailureAction = (action) => !!action.type.match(/::failure$/); | ||
export const isCompleteAction = (action) => isSuccessAction(action) || isFailureAction(action); | ||
export const actionBaseType = (action) => action.type.replace(/::\w+$/, ''); | ||
export const actionSuffixDivider = '::'; | ||
export const matchActionSuffix = (suffix) => new RegExp(`${actionSuffixDivider}\\${suffix}$`); | ||
export const actionBaseType = (action) => action.type.replace(matchActionSuffix('\\w+$'), ''); | ||
export function getType(actionCreator) { | ||
@@ -37,0 +22,0 @@ return `${actionCreator}`; |
@@ -5,5 +5,7 @@ export * from './FlowSubject'; | ||
export { FlowSubject as ReactiveObservable } from './FlowSubject'; | ||
export { createAction, createAsyncAction } from './create-action'; | ||
export { actionMapper } from './action-mapper'; | ||
export { createAction, actionBaseType } from './create-action'; | ||
export { createAsyncAction, isRequestAction, isCompleteAction, isFailureAction, isSuccessAction, } from './create-async-action'; | ||
export { createReducer } from './create-reducer'; | ||
export { createState } from './create-state'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { Action, AnyAction, PayloadAction } from './types/actions'; | ||
import { Action, PayloadAction } from './types/actions'; | ||
import { IfMaybeUndefined, IfVoid, IsAny, IsUnknownOrNonInferrable } from './types/ts-helpers'; | ||
@@ -43,12 +43,4 @@ export type PrepareAction<P> = ((...args: any[]) => { | ||
export declare function createAction<PA extends PrepareAction<any>, T extends string = string>(type: T, prepareAction: PA): PayloadActionCreator<ReturnType<PA>['payload'], T, PA>; | ||
export declare function createAsyncAction<PA extends PrepareAction<any>, PA_Success extends PrepareAction<any>, T extends string = string>(type: T, request: PA, success: PA_Success): PayloadActionCreator<ReturnType<PA>['payload'], T, PA> & { | ||
success: PayloadActionCreator<ReturnType<PA_Success>['payload'], `${T}::success`, PA_Success>; | ||
}; | ||
export declare function createAsyncAction<PA extends PrepareAction<any>, PA_Success extends PrepareAction<any>, PA_Failure extends PrepareAction<any>, T extends string = string>(type: T, request: PA, success: PA_Success, failure: PA_Failure): PayloadActionCreator<ReturnType<PA>['payload'], T, PA> & { | ||
success: PayloadActionCreator<ReturnType<PA_Success>['payload'], `${T}::success`, PA_Success>; | ||
failure: PayloadActionCreator<ReturnType<PA_Failure>['payload'], `${T}::failure`, PA_Failure>; | ||
}; | ||
export declare const isSuccessAction: <A extends AnyAction>(action: A) => action is A; | ||
export declare const isFailureAction: <A extends AnyAction>(action: A) => action is A; | ||
export declare const isCompleteAction: <A extends AnyAction>(action: A) => action is A; | ||
export declare const actionSuffixDivider = "::"; | ||
export declare const matchActionSuffix: (suffix: string) => RegExp; | ||
export declare const actionBaseType: (action: Action) => string; | ||
@@ -55,0 +47,0 @@ export declare function getType<T extends string>(actionCreator: PayloadActionCreator<any, T>): T; |
@@ -5,4 +5,6 @@ export * from './FlowSubject'; | ||
export { FlowSubject as ReactiveObservable } from './FlowSubject'; | ||
export { createAction, createAsyncAction } from './create-action'; | ||
export { actionMapper } from './action-mapper'; | ||
export { createAction, actionBaseType } from './create-action'; | ||
export { createAsyncAction, isRequestAction, isCompleteAction, isFailureAction, isSuccessAction, } from './create-async-action'; | ||
export { createReducer } from './create-reducer'; | ||
export { createState } from './create-state'; |
{ | ||
"name": "@equinor/fusion-observable", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "WIP", | ||
@@ -12,3 +12,3 @@ "private": false, | ||
], | ||
"homepage": "https://github.com/equinor/fusion-framework/tree/master/packages/observable#readme", | ||
"homepage": "https://equinor.github.io/fusion-framework/", | ||
"license": "ISC", | ||
@@ -43,3 +43,4 @@ "main": "dist/esm/index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/equinor/fusion-framework.git" | ||
"url": "git+https://github.com/equinor/fusion-framework.git", | ||
"directory": "utils/observable" | ||
}, | ||
@@ -83,3 +84,3 @@ "scripts": { | ||
}, | ||
"gitHead": "3bb1fed86aad515b594dad564444575ef552d87d" | ||
"gitHead": "e100691d856a7c6dc3c815a6d462f0ccf8f97f98" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
137227
91
679
0