Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

overmind

Package Overview
Dependencies
Maintainers
4
Versions
886
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

overmind - npm Package Compare versions

Comparing version 1.0.0-1532598454955 to 1.0.0-1532612418339

36

es/Action.d.ts
import { ActionBase } from 'action-chain';
declare type OperatorCallback<Context, Value, NewValue = Value> = (context: Context, value: Value) => NewValue | Promise<NewValue>;
export interface IValueAction<State, Context, InitialValue, Value = InitialValue> extends Action<State, Context, InitialValue, Value> {
declare type OperatorCallback<Effects, Value, NewValue = Value> = (effects: Effects, value: Value) => NewValue | Promise<NewValue>;
export interface IValueAction<State, Effects, InitialValue, Value = InitialValue> extends Action<State, Effects, InitialValue, Value> {
(value: InitialValue): Value;
}
export interface INoValueAction<State, Context, InitialValue, Value = InitialValue> extends Action<State, Context, InitialValue, Value> {
export interface INoValueAction<State, Effects, InitialValue, Value = InitialValue> extends Action<State, Effects, InitialValue, Value> {
(): Value;
}
export default class Action<State, Context, InitialValue, Value = InitialValue> extends ActionBase<Context, InitialValue, Value> {
export default class Action<State, Effects, InitialValue, Value = InitialValue> extends ActionBase<Effects> {
private proxyStateTree;
constructor(proxyStateTree: any, actionChain: any, initialActionId?: any, runOperators?: any);
fork: <Paths>(cb: (context: Context, value: Value) => keyof Paths, paths: Paths) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, Value> : IValueAction<State, Context, InitialValue, Value>;
mutation: (cb: (state: State, value: Value) => any) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, Value> : IValueAction<State, Context, InitialValue, Value>;
do: (cb: (context: Context, value: Value) => void) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, Value> : IValueAction<State, Context, InitialValue, Value>;
map: <NewValue>(cb: (context: Context, value: Value) => NewValue | Promise<NewValue>) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, NewValue> : IValueAction<State, Context, InitialValue, NewValue>;
try: <ResolveValue, RejectValue, NewValue>(cb: OperatorCallback<Context, Value, NewValue>, paths: {
success: Action<State, Context, ReturnType<OperatorCallback<Context, Value, NewValue>>, ResolveValue>;
error: Action<State, Context, ReturnType<OperatorCallback<Context, Value, NewValue>>, RejectValue>;
}) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, ResolveValue | RejectValue> : IValueAction<State, Context, InitialValue, ResolveValue | RejectValue>;
when: <TrueValue, FalseValue>(cb: (context: Context, value: Value) => boolean, paths: {
true: Action<State, Context, Value, TrueValue>;
false: Action<State, Context, Value, FalseValue>;
}) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, TrueValue | FalseValue> : IValueAction<State, Context, InitialValue, TrueValue | FalseValue>;
filter: (cb: (context: Context, value: Value) => boolean) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, Value> : IValueAction<State, Context, InitialValue, Value>;
debounce: (timer: number) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, Value> : IValueAction<State, Context, InitialValue, Value>;
fork: <Paths>(cb: (effects: Effects, value: Value) => keyof Paths, paths: Paths) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, Value> : IValueAction<State, Effects, InitialValue, Value>;
mutation: (cb: (state: State, value: Value) => any) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, Value> : IValueAction<State, Effects, InitialValue, Value>;
do: (cb: (effects: Effects, value: Value) => void) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, Value> : IValueAction<State, Effects, InitialValue, Value>;
map: <NewValue>(cb: (effects: Effects, value: Value) => NewValue | Promise<NewValue>) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, NewValue> : IValueAction<State, Effects, InitialValue, NewValue>;
try: <ResolveValue, RejectValue, NewValue>(cb: OperatorCallback<Effects, Value, NewValue>, paths: {
success: Action<State, Effects, ReturnType<OperatorCallback<Effects, Value, NewValue>>, ResolveValue>;
error: Action<State, Effects, ReturnType<OperatorCallback<Effects, Value, NewValue>>, RejectValue>;
}) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, ResolveValue | RejectValue> : IValueAction<State, Effects, InitialValue, ResolveValue | RejectValue>;
when: <TrueValue, FalseValue>(cb: (effects: Effects, value: Value) => boolean, paths: {
true: Action<State, Effects, Value, TrueValue>;
false: Action<State, Effects, Value, FalseValue>;
}) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, TrueValue | FalseValue> : IValueAction<State, Effects, InitialValue, TrueValue | FalseValue>;
filter: (cb: (effects: Effects, value: Value) => boolean) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, Value> : IValueAction<State, Effects, InitialValue, Value>;
debounce: (timer: number) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, Value> : IValueAction<State, Effects, InitialValue, Value>;
}
export {};

@@ -6,5 +6,5 @@ import { ActionBase, StopExecution } from 'action-chain';

this.fork = (cb, paths) => {
const operator = (context, value) => {
const path = cb(context, value);
return paths[path].map(() => value)(value, context, path);
const operator = (effects, value) => {
const path = cb(effects, value);
return paths[path].map(() => value)(value, effects, path);
};

@@ -15,7 +15,7 @@ const [chain, initialActionId, runOperators] = this.createOperatorResult('fork', cb.name, operator);

this.mutation = (cb) => {
const operator = (context, value) => {
const operator = (effects, value) => {
this.proxyStateTree.startMutationTracking();
cb(context.state, value);
cb(effects.state, value);
const mutations = this.proxyStateTree.clearMutationTracking();
this.getActionChain().emit('mutations', Object.assign({ mutations }, context.__execution));
this.getActionChain().emit('mutations', Object.assign({ mutations }, effects.__execution));
return value;

@@ -27,4 +27,4 @@ };

this.do = (cb) => {
const operator = (context, value) => {
cb(context, value);
const operator = (effects, value) => {
cb(effects, value);
return value;

@@ -40,9 +40,9 @@ };

this.try = (cb, paths) => {
const operator = (context, value) => {
return cb(context, value)
const operator = (effects, value) => {
return cb(effects, value)
.then((promiseValue) => {
return paths.success(promiseValue, context, 'success');
return paths.success(promiseValue, effects, 'success');
})
.catch((error) => {
return paths.error(error, context, 'error');
return paths.error(error, effects, 'error');
});

@@ -54,6 +54,6 @@ };

this.when = (cb, paths) => {
const operator = (context, value) => {
const isTrue = cb(context, value);
const operator = (effects, value) => {
const isTrue = cb(effects, value);
const path = isTrue ? paths.true : paths.false;
return path(value, context, isTrue ? 'true' : 'false');
return path(value, effects, isTrue ? 'true' : 'false');
};

@@ -64,4 +64,4 @@ const [chain, initialActionId, runOperators] = this.createOperatorResult('when', cb.name, operator);

this.filter = (cb) => {
const operator = (context, value) => {
const result = cb(context, value);
const operator = (effects, value) => {
const result = cb(effects, value);
if (result === true) {

@@ -68,0 +68,0 @@ return value;

@@ -7,5 +7,5 @@ import Devtools from './Devtools';

export { default as computed } from './computed';
declare type Configuration<State, Providers, Actions, Reactions> = {
declare type Configuration<State, Effects, Actions, Reactions> = {
state?: State;
providers?: Providers;
effects?: Effects;
actions?: Actions;

@@ -51,17 +51,17 @@ reactions?: Reactions;

}
export declare type ActionsCallback<Providers, State> = (action: IAction<State, Providers & {
export declare type ActionsCallback<Effects, State> = (action: TAction<State, Effects & {
state: State;
}>) => any;
export declare type ReactionsCallback<State, Providers> = (reaction: ReactionConfig<State, Providers>, action: IAction<State, Providers & {
export declare type ReactionsCallback<State, Effects> = (reaction: ReactionConfig<State, Effects>, action: TAction<State, Effects & {
state: State;
}>) => any;
export declare type TContext<State, Providers = {}> = Providers & {
export declare type TEffects<State, Effects = {}> = Effects & {
state: State;
};
export interface IAction<State, Context> {
export declare type TAction<State, Context> = {
<InitialValue = void>(): [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue> : IValueAction<State, Context, InitialValue>;
}
export default class App<State extends object, Providers extends object, Reactions extends ReactionsCallback<State, Providers> | {
};
export default class App<State extends object, Effects extends object, Reactions extends ReactionsCallback<State, Effects> | {
[namespace: string]: ReactionsCallback<State, any>;
}, Actions extends ActionsCallback<Providers, State> | {
}, Actions extends ActionsCallback<Effects, State> | {
[namespace: string]: ActionsCallback<{}, {}>;

@@ -72,3 +72,3 @@ }> {

devtools: Devtools;
actions: Actions extends ActionsCallback<Providers, State> ? ReturnType<Actions> : Actions extends {
actions: Actions extends ActionsCallback<Effects, State> ? ReturnType<Actions> : Actions extends {
[namespace: string]: ActionsCallback<{}, {}>;

@@ -79,3 +79,3 @@ } ? {

state: State;
constructor(configuration: Configuration<State, Providers, Actions, Reactions>, options?: Options);
constructor(configuration: Configuration<State, Effects, Actions, Reactions>, options?: Options);
private initializeDevtools;

@@ -82,0 +82,0 @@ private initializeReactions;

@@ -28,3 +28,3 @@ import { ActionChain } from 'action-chain';

state: proxyStateTree.get(),
}, configuration.providers || {}), {
}, configuration.effects || {}), {
providerExceptions: ['state'],

@@ -31,0 +31,0 @@ });

@@ -14,3 +14,3 @@ import App, { namespaces } from './';

state: {},
providers: {},
effects: {},
actions: (action) => ({

@@ -106,3 +106,3 @@ foo: action(),

},
providers: {
effects: {
foo: {

@@ -109,0 +109,0 @@ bar: () => 'baz',

import * as React from 'react';
import App, { ActionsCallback, ReactionsCallback } from '../';
export { TContext, IAction, namespaces } from '../';
export { TEffects, TAction, namespaces } from '../';
export declare type IReactComponent<P = any> = React.StatelessComponent<P> | React.ComponentClass<P> | React.ClassicComponentClass<P>;

@@ -5,0 +5,0 @@ export declare type TConnect<State = {}, Actions = {}> = {

import { ActionBase } from 'action-chain';
declare type OperatorCallback<Context, Value, NewValue = Value> = (context: Context, value: Value) => NewValue | Promise<NewValue>;
export interface IValueAction<State, Context, InitialValue, Value = InitialValue> extends Action<State, Context, InitialValue, Value> {
declare type OperatorCallback<Effects, Value, NewValue = Value> = (effects: Effects, value: Value) => NewValue | Promise<NewValue>;
export interface IValueAction<State, Effects, InitialValue, Value = InitialValue> extends Action<State, Effects, InitialValue, Value> {
(value: InitialValue): Value;
}
export interface INoValueAction<State, Context, InitialValue, Value = InitialValue> extends Action<State, Context, InitialValue, Value> {
export interface INoValueAction<State, Effects, InitialValue, Value = InitialValue> extends Action<State, Effects, InitialValue, Value> {
(): Value;
}
export default class Action<State, Context, InitialValue, Value = InitialValue> extends ActionBase<Context, InitialValue, Value> {
export default class Action<State, Effects, InitialValue, Value = InitialValue> extends ActionBase<Effects> {
private proxyStateTree;
constructor(proxyStateTree: any, actionChain: any, initialActionId?: any, runOperators?: any);
fork: <Paths>(cb: (context: Context, value: Value) => keyof Paths, paths: Paths) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, Value> : IValueAction<State, Context, InitialValue, Value>;
mutation: (cb: (state: State, value: Value) => any) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, Value> : IValueAction<State, Context, InitialValue, Value>;
do: (cb: (context: Context, value: Value) => void) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, Value> : IValueAction<State, Context, InitialValue, Value>;
map: <NewValue>(cb: (context: Context, value: Value) => NewValue | Promise<NewValue>) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, NewValue> : IValueAction<State, Context, InitialValue, NewValue>;
try: <ResolveValue, RejectValue, NewValue>(cb: OperatorCallback<Context, Value, NewValue>, paths: {
success: Action<State, Context, ReturnType<OperatorCallback<Context, Value, NewValue>>, ResolveValue>;
error: Action<State, Context, ReturnType<OperatorCallback<Context, Value, NewValue>>, RejectValue>;
}) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, ResolveValue | RejectValue> : IValueAction<State, Context, InitialValue, ResolveValue | RejectValue>;
when: <TrueValue, FalseValue>(cb: (context: Context, value: Value) => boolean, paths: {
true: Action<State, Context, Value, TrueValue>;
false: Action<State, Context, Value, FalseValue>;
}) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, TrueValue | FalseValue> : IValueAction<State, Context, InitialValue, TrueValue | FalseValue>;
filter: (cb: (context: Context, value: Value) => boolean) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, Value> : IValueAction<State, Context, InitialValue, Value>;
debounce: (timer: number) => [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue, Value> : IValueAction<State, Context, InitialValue, Value>;
fork: <Paths>(cb: (effects: Effects, value: Value) => keyof Paths, paths: Paths) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, Value> : IValueAction<State, Effects, InitialValue, Value>;
mutation: (cb: (state: State, value: Value) => any) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, Value> : IValueAction<State, Effects, InitialValue, Value>;
do: (cb: (effects: Effects, value: Value) => void) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, Value> : IValueAction<State, Effects, InitialValue, Value>;
map: <NewValue>(cb: (effects: Effects, value: Value) => NewValue | Promise<NewValue>) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, NewValue> : IValueAction<State, Effects, InitialValue, NewValue>;
try: <ResolveValue, RejectValue, NewValue>(cb: OperatorCallback<Effects, Value, NewValue>, paths: {
success: Action<State, Effects, ReturnType<OperatorCallback<Effects, Value, NewValue>>, ResolveValue>;
error: Action<State, Effects, ReturnType<OperatorCallback<Effects, Value, NewValue>>, RejectValue>;
}) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, ResolveValue | RejectValue> : IValueAction<State, Effects, InitialValue, ResolveValue | RejectValue>;
when: <TrueValue, FalseValue>(cb: (effects: Effects, value: Value) => boolean, paths: {
true: Action<State, Effects, Value, TrueValue>;
false: Action<State, Effects, Value, FalseValue>;
}) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, TrueValue | FalseValue> : IValueAction<State, Effects, InitialValue, TrueValue | FalseValue>;
filter: (cb: (effects: Effects, value: Value) => boolean) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, Value> : IValueAction<State, Effects, InitialValue, Value>;
debounce: (timer: number) => [InitialValue] extends [void] ? INoValueAction<State, Effects, InitialValue, Value> : IValueAction<State, Effects, InitialValue, Value>;
}
export {};

@@ -8,5 +8,5 @@ "use strict";

this.fork = (cb, paths) => {
const operator = (context, value) => {
const path = cb(context, value);
return paths[path].map(() => value)(value, context, path);
const operator = (effects, value) => {
const path = cb(effects, value);
return paths[path].map(() => value)(value, effects, path);
};

@@ -17,7 +17,7 @@ const [chain, initialActionId, runOperators] = this.createOperatorResult('fork', cb.name, operator);

this.mutation = (cb) => {
const operator = (context, value) => {
const operator = (effects, value) => {
this.proxyStateTree.startMutationTracking();
cb(context.state, value);
cb(effects.state, value);
const mutations = this.proxyStateTree.clearMutationTracking();
this.getActionChain().emit('mutations', Object.assign({ mutations }, context.__execution));
this.getActionChain().emit('mutations', Object.assign({ mutations }, effects.__execution));
return value;

@@ -29,4 +29,4 @@ };

this.do = (cb) => {
const operator = (context, value) => {
cb(context, value);
const operator = (effects, value) => {
cb(effects, value);
return value;

@@ -42,9 +42,9 @@ };

this.try = (cb, paths) => {
const operator = (context, value) => {
return cb(context, value)
const operator = (effects, value) => {
return cb(effects, value)
.then((promiseValue) => {
return paths.success(promiseValue, context, 'success');
return paths.success(promiseValue, effects, 'success');
})
.catch((error) => {
return paths.error(error, context, 'error');
return paths.error(error, effects, 'error');
});

@@ -56,6 +56,6 @@ };

this.when = (cb, paths) => {
const operator = (context, value) => {
const isTrue = cb(context, value);
const operator = (effects, value) => {
const isTrue = cb(effects, value);
const path = isTrue ? paths.true : paths.false;
return path(value, context, isTrue ? 'true' : 'false');
return path(value, effects, isTrue ? 'true' : 'false');
};

@@ -66,4 +66,4 @@ const [chain, initialActionId, runOperators] = this.createOperatorResult('when', cb.name, operator);

this.filter = (cb) => {
const operator = (context, value) => {
const result = cb(context, value);
const operator = (effects, value) => {
const result = cb(effects, value);
if (result === true) {

@@ -70,0 +70,0 @@ return value;

@@ -7,5 +7,5 @@ import Devtools from './Devtools';

export { default as computed } from './computed';
declare type Configuration<State, Providers, Actions, Reactions> = {
declare type Configuration<State, Effects, Actions, Reactions> = {
state?: State;
providers?: Providers;
effects?: Effects;
actions?: Actions;

@@ -51,17 +51,17 @@ reactions?: Reactions;

}
export declare type ActionsCallback<Providers, State> = (action: IAction<State, Providers & {
export declare type ActionsCallback<Effects, State> = (action: TAction<State, Effects & {
state: State;
}>) => any;
export declare type ReactionsCallback<State, Providers> = (reaction: ReactionConfig<State, Providers>, action: IAction<State, Providers & {
export declare type ReactionsCallback<State, Effects> = (reaction: ReactionConfig<State, Effects>, action: TAction<State, Effects & {
state: State;
}>) => any;
export declare type TContext<State, Providers = {}> = Providers & {
export declare type TEffects<State, Effects = {}> = Effects & {
state: State;
};
export interface IAction<State, Context> {
export declare type TAction<State, Context> = {
<InitialValue = void>(): [InitialValue] extends [void] ? INoValueAction<State, Context, InitialValue> : IValueAction<State, Context, InitialValue>;
}
export default class App<State extends object, Providers extends object, Reactions extends ReactionsCallback<State, Providers> | {
};
export default class App<State extends object, Effects extends object, Reactions extends ReactionsCallback<State, Effects> | {
[namespace: string]: ReactionsCallback<State, any>;
}, Actions extends ActionsCallback<Providers, State> | {
}, Actions extends ActionsCallback<Effects, State> | {
[namespace: string]: ActionsCallback<{}, {}>;

@@ -72,3 +72,3 @@ }> {

devtools: Devtools;
actions: Actions extends ActionsCallback<Providers, State> ? ReturnType<Actions> : Actions extends {
actions: Actions extends ActionsCallback<Effects, State> ? ReturnType<Actions> : Actions extends {
[namespace: string]: ActionsCallback<{}, {}>;

@@ -79,3 +79,3 @@ } ? {

state: State;
constructor(configuration: Configuration<State, Providers, Actions, Reactions>, options?: Options);
constructor(configuration: Configuration<State, Effects, Actions, Reactions>, options?: Options);
private initializeDevtools;

@@ -82,0 +82,0 @@ private initializeReactions;

@@ -33,3 +33,3 @@ "use strict";

state: proxyStateTree.get(),
}, configuration.providers || {}), {
}, configuration.effects || {}), {
providerExceptions: ['state'],

@@ -36,0 +36,0 @@ });

@@ -16,3 +16,3 @@ "use strict";

state: {},
providers: {},
effects: {},
actions: (action) => ({

@@ -108,3 +108,3 @@ foo: action(),

},
providers: {
effects: {
foo: {

@@ -111,0 +111,0 @@ bar: () => 'baz',

import * as React from 'react';
import App, { ActionsCallback, ReactionsCallback } from '../';
export { TContext, IAction, namespaces } from '../';
export { TEffects, TAction, namespaces } from '../';
export declare type IReactComponent<P = any> = React.StatelessComponent<P> | React.ComponentClass<P> | React.ClassicComponentClass<P>;

@@ -5,0 +5,0 @@ export declare type TConnect<State = {}, Actions = {}> = {

{
"name": "overmind",
"version": "1.0.0-1532598454955",
"version": "1.0.0-1532612418339",
"description": "Functional actions",

@@ -41,6 +41,6 @@ "author": "Christian Alfoni <christianalfoni@gmail.com>",

"@types/node": "^10.5.1",
"action-chain": "1.0.0-1532598454955",
"action-chain": "1.0.0-1532612418339",
"is-plain-object": "^2.0.4",
"betsy": "1.0.0-1532598454955",
"proxy-state-tree": "1.0.0-1532598454955",
"betsy": "1.0.0-1532612418339",
"proxy-state-tree": "1.0.0-1532612418339",
"tslib": "^1.9.3"

@@ -47,0 +47,0 @@ },

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc