Socket
Socket
Sign inDemoInstall

@typescript-tea/core

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.3.0-0

2

dist/cmd.d.ts

@@ -10,3 +10,3 @@ import { LeafEffect, batchEffects, mapEffect } from "./effect";

*/
export declare type Cmd<A> = LeafEffect<A>;
export declare type Cmd<Action> = LeafEffect<Action>;
/**

@@ -13,0 +13,0 @@ * When you need the runtime system to perform a couple commands, you

import { Dispatch } from "./dispatch";
import { LeafEffect, LeafEffectMapper } from "./effect";
/**
* A function that will be called by the runtime with the effects (commands and subscriptions)
* that was gathered for the effect manager.
*/
export declare type OnEffects<AppAction, SelfAction, State> = (dispatchApp: Dispatch<AppAction>, dispatchSelf: Dispatch<SelfAction>, cmds: ReadonlyArray<LeafEffect<AppAction>>, subs: ReadonlyArray<LeafEffect<AppAction>>, state: State) => State;
/**
* A function that will be called by the runtime with the actions that an effect manager
* dispatches to itself.
*/
export declare type OnSelfAction<AppAction, SelfAction, State> = (dispatchApp: Dispatch<AppAction>, dispatchSelf: Dispatch<SelfAction>, action: SelfAction, state: State) => State;
/**
* A type that describes an effect manager that can be used by the runtime.
*/
export declare type EffectManager<AppAction = unknown, SelfAction = unknown, State = unknown, THome = unknown> = {
readonly home: THome;
export declare type EffectManager<Home = unknown, ProgramAction = unknown, SelfAction = unknown, SelfState = unknown, MyCmd extends LeafEffect<ProgramAction, Home> = LeafEffect<ProgramAction, Home>, MySub extends LeafEffect<ProgramAction, Home> = LeafEffect<ProgramAction, Home>> = {
readonly home: Home;
readonly mapCmd: LeafEffectMapper;
readonly mapSub: LeafEffectMapper;
readonly onEffects: OnEffects<AppAction, SelfAction, State>;
readonly onSelfAction: OnSelfAction<AppAction, SelfAction, State>;
readonly onEffects: (dispatchProgram: Dispatch<ProgramAction>, dispatchSelf: Dispatch<SelfAction>, cmds: ReadonlyArray<MyCmd>, subs: ReadonlyArray<MySub>, state: SelfState) => SelfState;
readonly onSelfAction: (dispatchProgram: Dispatch<ProgramAction>, dispatchSelf: Dispatch<SelfAction>, action: SelfAction, state: SelfState) => SelfState;
};

@@ -23,0 +13,0 @@ /** @ignore */

@@ -13,4 +13,4 @@ /**

export declare type InternalHome = typeof InternalHome;
export declare type LeafEffect<_A> = {
readonly home: string;
export declare type LeafEffect<_A, Home = string> = {
readonly home: Home;
readonly type: string;

@@ -17,0 +17,0 @@ };

@@ -8,11 +8,11 @@ import { Cmd } from "./cmd";

*/
export declare type Program<S, A, V> = {
readonly init: (url: string, key: () => void) => readonly [S, Cmd<A>?];
readonly update: (action: A, state: S) => readonly [S, Cmd<A>?];
export declare type Program<State, Action, View> = {
readonly init: (url: string, key: () => void) => readonly [State, Cmd<Action>?];
readonly update: (action: Action, state: State) => readonly [State, Cmd<Action>?];
readonly view: (props: {
readonly state: S;
readonly dispatch: Dispatch<A>;
}) => V;
readonly subscriptions?: (state: S) => Sub<A> | undefined;
readonly onUrlChange?: (url: string) => A;
readonly state: State;
readonly dispatch: Dispatch<Action>;
}) => View;
readonly subscriptions?: (state: State) => Sub<Action> | undefined;
readonly onUrlChange?: (url: string) => Action;
};

@@ -19,0 +19,0 @@ /**

@@ -13,3 +13,3 @@ import { LeafEffect, batchEffects, mapEffect } from "./effect";

*/
export declare type Sub<A> = LeafEffect<A>;
export declare type Sub<Action> = LeafEffect<Action>;
/**

@@ -16,0 +16,0 @@ * When you need to subscribe to multiple things, you can create a `batch` of

{
"name": "@typescript-tea/core",
"version": "0.2.0",
"version": "0.3.0-0",
"description": "The Elm Architecture for typescript",

@@ -5,0 +5,0 @@ "main": "dist/core.js",

@@ -13,3 +13,3 @@ import { LeafEffect, batchEffects, mapEffect } from "./effect";

*/
export type Cmd<A> = LeafEffect<A>;
export type Cmd<Action> = LeafEffect<Action>;

@@ -16,0 +16,0 @@ /**

@@ -5,33 +5,28 @@ import { Dispatch } from "./dispatch";

/**
* A function that will be called by the runtime with the effects (commands and subscriptions)
* that was gathered for the effect manager.
*/
export type OnEffects<AppAction, SelfAction, State> = (
dispatchApp: Dispatch<AppAction>,
dispatchSelf: Dispatch<SelfAction>,
cmds: ReadonlyArray<LeafEffect<AppAction>>,
subs: ReadonlyArray<LeafEffect<AppAction>>,
state: State
) => State;
/**
* A function that will be called by the runtime with the actions that an effect manager
* dispatches to itself.
*/
export type OnSelfAction<AppAction, SelfAction, State> = (
dispatchApp: Dispatch<AppAction>,
dispatchSelf: Dispatch<SelfAction>,
action: SelfAction,
state: State
) => State;
/**
* A type that describes an effect manager that can be used by the runtime.
*/
export type EffectManager<AppAction = unknown, SelfAction = unknown, State = unknown, THome = unknown> = {
readonly home: THome;
export type EffectManager<
Home = unknown,
ProgramAction = unknown,
SelfAction = unknown,
SelfState = unknown,
MyCmd extends LeafEffect<ProgramAction, Home> = LeafEffect<ProgramAction, Home>,
MySub extends LeafEffect<ProgramAction, Home> = LeafEffect<ProgramAction, Home>
> = {
readonly home: Home;
readonly mapCmd: LeafEffectMapper;
readonly mapSub: LeafEffectMapper;
readonly onEffects: OnEffects<AppAction, SelfAction, State>;
readonly onSelfAction: OnSelfAction<AppAction, SelfAction, State>;
readonly onEffects: (
dispatchProgram: Dispatch<ProgramAction>,
dispatchSelf: Dispatch<SelfAction>,
cmds: ReadonlyArray<MyCmd>,
subs: ReadonlyArray<MySub>,
state: SelfState
) => SelfState;
readonly onSelfAction: (
dispatchProgram: Dispatch<ProgramAction>,
dispatchSelf: Dispatch<SelfAction>,
action: SelfAction,
state: SelfState
) => SelfState;
};

@@ -38,0 +33,0 @@

@@ -15,4 +15,4 @@ /**

export type LeafEffect<_A> = {
readonly home: string;
export type LeafEffect<_A, Home = string> = {
readonly home: Home;
readonly type: string;

@@ -19,0 +19,0 @@ };

@@ -10,8 +10,8 @@ import { Cmd } from "./cmd";

*/
export type Program<S, A, V> = {
readonly init: (url: string, key: () => void) => readonly [S, Cmd<A>?];
readonly update: (action: A, state: S) => readonly [S, Cmd<A>?];
readonly view: (props: { readonly state: S; readonly dispatch: Dispatch<A> }) => V;
readonly subscriptions?: (state: S) => Sub<A> | undefined;
readonly onUrlChange?: (url: string) => A;
export type Program<State, Action, View> = {
readonly init: (url: string, key: () => void) => readonly [State, Cmd<Action>?];
readonly update: (action: Action, state: State) => readonly [State, Cmd<Action>?];
readonly view: (props: { readonly state: State; readonly dispatch: Dispatch<Action> }) => View;
readonly subscriptions?: (state: State) => Sub<Action> | undefined;
readonly onUrlChange?: (url: string) => Action;
};

@@ -57,3 +57,3 @@

const enqueueSelfAction = enqueueManagerAction(home);
managerStates[home] = manager.onSelfAction(enqueueAppAction, enqueueSelfAction, action, managerStates[home]);
managerStates[home] = manager.onSelfAction(enqueueProgramAction, enqueueSelfAction, action, managerStates[home]);
}

@@ -72,3 +72,3 @@ };

const enqueueAppAction = (action: A): void => {
const enqueueProgramAction = (action: A): void => {
enqueueRaw(dispatchApp, action);

@@ -95,3 +95,3 @@ };

managerStates[home] = manager.onEffects(
enqueueAppAction,
enqueueProgramAction,
enqueueManagerAction(home),

@@ -103,3 +103,3 @@ cmds,

}
render(view({ state, dispatch: enqueueAppAction }));
render(view({ state, dispatch: enqueueProgramAction }));
}

@@ -119,3 +119,3 @@

if (program.onUrlChange) {
enqueueAppAction(program.onUrlChange(getCurrentUrl()));
enqueueProgramAction(program.onUrlChange(getCurrentUrl()));
}

@@ -122,0 +122,0 @@ }

@@ -16,3 +16,3 @@ import { LeafEffect, batchEffects, mapEffect } from "./effect";

*/
export type Sub<A> = LeafEffect<A>;
export type Sub<Action> = LeafEffect<Action>;

@@ -19,0 +19,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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc