@bunt/unit
Advanced tools
Comparing version 0.24.0 to 0.24.1
@@ -8,1 +8,2 @@ export * from "./interfaces"; | ||
export * from "./Dispose"; | ||
export * from "./fn"; |
@@ -24,2 +24,3 @@ "use strict"; | ||
__exportStar(require("./Dispose"), exports); | ||
__exportStar(require("./fn"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { Promisify } from "@bunt/util"; | ||
import { Fn, Promisify } from "@bunt/util"; | ||
import { Action } from "./Action"; | ||
@@ -6,10 +6,13 @@ import { ApplyContext, Context } from "./Context"; | ||
export declare type ContextArg<C extends Context> = (() => Promisify<C>) | Promisify<C>; | ||
export declare type ActionCtor<C extends Context, S extends StateType | null = any, R = unknown, A extends Action<C, S, R> = Action<C, S, R>> = { | ||
new (context: ApplyContext<C>, state: S): A; | ||
export declare type ActionCtor<A extends ActionAny> = { | ||
new (context: ApplyContext<ActionContext<A>>, state: ActionState<A>): A; | ||
prototype: A; | ||
}; | ||
export declare type ActionCtorImport<C extends Context, S extends StateType | null = any, R = unknown, A extends Action<C, S, R> = Action<C, S, R>> = () => Promise<{ | ||
default: ActionCtor<C, S, R, A>; | ||
}>; | ||
export declare type ActionFactory<C extends Context, S extends StateType | null = any, R = unknown, A extends Action<C, S, R> = Action<C, S, R>> = ActionCtor<C, S, R, A> | ActionCtorImport<C, S, R, A>; | ||
export declare type ActionImport<A extends ActionAny> = Fn<[], Promise<{ | ||
default: ActionCtor<A>; | ||
}>>; | ||
export declare type AsyncActionFactory<A extends ActionAny> = { | ||
factory: ActionImport<A>; | ||
}; | ||
export declare type ActionFactory<A extends ActionAny> = ActionCtor<A> | AsyncActionFactory<A>; | ||
export declare type ActionContext<A> = A extends ActionAny<infer T> ? T : never; | ||
@@ -16,0 +19,0 @@ export declare type ActionState<A> = A extends ActionAny<any, infer T> ? T : never; |
import { Logger } from "@bunt/util"; | ||
import { ApplyContext, Context } from "./Context"; | ||
import { Action } from "./Action"; | ||
import { ActionCtor, ActionFactory, ActionReturn, ActionState, ContextArg, StateType } from "./interfaces"; | ||
import { ActionAny, ActionCtor, ActionFactory, ActionReturn, ActionState, ContextArg } from "./interfaces"; | ||
export declare class Unit<C extends Context> { | ||
@@ -13,3 +12,3 @@ #private; | ||
protected static getContext<C extends Context>(context: ContextArg<C>): Promise<ApplyContext<C>>; | ||
run<A extends Action<C, S, R>, S extends StateType, R = unknown>(factory: ActionFactory<C, S, R, A>, state: ActionState<A>): Promise<ActionReturn<Action<C, S, R>>>; | ||
run<A extends ActionAny<C>>(factory: ActionFactory<A>, state: ActionState<A>): Promise<ActionReturn<A>>; | ||
static getAction(action: ActionFactory<any>): Promise<ActionCtor<any>>; | ||
@@ -16,0 +15,0 @@ private static isActionFactory; |
@@ -56,3 +56,3 @@ "use strict"; | ||
if (this.isActionFactory(action)) { | ||
const { default: ctor } = await action(); | ||
const { default: ctor } = await action.factory(); | ||
return ctor; | ||
@@ -59,0 +59,0 @@ } |
{ | ||
"name": "@bunt/unit", | ||
"version": "0.24.0", | ||
"version": "0.24.1", | ||
"keywords": [ | ||
@@ -32,3 +32,3 @@ "typescript" | ||
"license": "MIT", | ||
"gitHead": "870927e58da8dcc164c48be4bb13ddb171c5b1fd" | ||
"gitHead": "94b67a8bf9440c40e0c33ed8931d85f23dca7af4" | ||
} |
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
62019
77
981