Comparing version 4.0.0-beta2 to 4.0.0-beta3
@@ -6,2 +6,5 @@ "use strict"; | ||
var createStoreAction = mobx_1.action('createStore', function createStoreAction(key, initialState) { | ||
if (getRootStore_1.default().get(key)) { | ||
throw new Error("A store named " + key + " has already been created."); | ||
} | ||
getRootStore_1.default().set(key, initialState); | ||
@@ -8,0 +11,0 @@ }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var mobx_1 = require("mobx"); | ||
var actionCreator_1 = require("./actionCreator"); | ||
@@ -18,3 +19,5 @@ var globalContext_1 = require("./globalContext"); | ||
var dispatchWithMiddleware = globalContext_1.getGlobalContext().dispatchWithMiddleware || finalDispatch; | ||
dispatchWithMiddleware(actionMessage); | ||
mobx_1.transaction(function () { | ||
dispatchWithMiddleware(actionMessage); | ||
}); | ||
} | ||
@@ -21,0 +24,0 @@ exports.dispatch = dispatch; |
@@ -15,5 +15,5 @@ import useStrict from './useStrict'; | ||
export { default as getRootStore } from './getRootStore'; | ||
export { mutatorAction, orchestratorAction } from './simpleSubscribers'; | ||
export { mutatorAction } from './simpleSubscribers'; | ||
export { useStrict }; | ||
export declare const flow: typeof orchestrator; | ||
export { orchestrator }; |
@@ -22,4 +22,3 @@ "use strict"; | ||
exports.mutatorAction = simpleSubscribers_1.mutatorAction; | ||
exports.orchestratorAction = simpleSubscribers_1.orchestratorAction; | ||
exports.flow = orchestrator_1.default; | ||
useStrict_1.default(true); |
@@ -1,2 +0,1 @@ | ||
/// <reference types="react" /> | ||
import * as React from 'react'; | ||
@@ -3,0 +2,0 @@ import { SelectorFunction } from '../select'; |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
@@ -7,0 +10,0 @@ extendStatics(d, b); |
import SimpleAction from './interfaces/SimpleAction'; | ||
export declare function createSimpleSubscriber(decorator: Function): <T extends SimpleAction>(actionType: string, target: T) => T; | ||
export declare const mutatorAction: <T extends SimpleAction>(actionType: string, target: T) => T; | ||
export declare const orchestratorAction: <T extends SimpleAction>(actionType: string, target: T) => T; |
@@ -5,3 +5,2 @@ "use strict"; | ||
var mutator_1 = require("./mutator"); | ||
var orchestrator_1 = require("./orchestrator"); | ||
function createSimpleSubscriber(decorator) { | ||
@@ -22,2 +21,1 @@ return function simpleSubscriber(actionType, target) { | ||
exports.mutatorAction = createSimpleSubscriber(mutator_1.default); | ||
exports.orchestratorAction = createSimpleSubscriber(orchestrator_1.default); |
{ | ||
"name": "satcheljs", | ||
"version": "4.0.0-beta2", | ||
"version": "4.0.0-beta3", | ||
"description": "Store implementation for functional reactive flux.", | ||
@@ -32,3 +32,3 @@ "lint-staged": { | ||
"jasmine": "^2.6.0", | ||
"jest": "20.0.4", | ||
"jest": "24.5.0", | ||
"lint-staged": "~4.0.1", | ||
@@ -43,6 +43,7 @@ "mobx": "^4.4.0", | ||
"rimraf": "^2.5.4", | ||
"ts-jest": "^24.0.0", | ||
"tslint": "~5.5.0", | ||
"tslint-eslint-rules": "~4.1.1", | ||
"tslint-microsoft-contrib": "~5.0.1", | ||
"typescript": "~2.4.2" | ||
"typescript": "~3.3.4000" | ||
}, | ||
@@ -49,0 +50,0 @@ "peerDependencies": { |
@@ -5,3 +5,5 @@ # Satchel | ||
[![npm](https://img.shields.io/npm/v/satcheljs.svg)](https://www.npmjs.com/package/satcheljs) | ||
[![Build Status](https://travis-ci.org/Microsoft/satcheljs.svg?branch=master)](https://travis-ci.org/Microsoft/satcheljs) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
@@ -127,6 +129,6 @@ ## Influences | ||
### mutatorAction and orchestratorAction | ||
### mutatorAction | ||
In many cases a given action only needs to be handled by one mutator or orchestrator. | ||
Satchel provides these utility APIs which encapsulate action creation, dispatch, and handling in one simple function call. | ||
In many cases a given action only needs to be handled by one mutator. | ||
Satchel provides this utility API which encapsulates action creation, dispatch, and handling in one simple function call. | ||
@@ -146,14 +148,3 @@ The `addTodo` mutator above could be implemented as follows: | ||
An orchestrator can be created similarly: | ||
```typescript | ||
let requestAddTodo = orchestratorAction( | ||
'REQUEST_ADD_TODO', | ||
async function requestAddTodo(text: string) { | ||
await addTodoOnServer(actionMessage.text); | ||
addTodo(actionMessage.text); | ||
}); | ||
``` | ||
This is a succinct and easy way to write mutators and orchestrators, but it comes with a restriction: | ||
This is a succinct and easy way to write mutators, but it comes with a restriction: | ||
the action creator is not exposed, so no *other* mutators or orchestrators can subscribe to it. | ||
@@ -160,0 +151,0 @@ If an action needs multiple handlers then it must use the full pattern with action creators and handlers implemented separately. |
Sorry, the diff of this file is not supported yet
221659
91
1033
23
151