Comparing version 1.0.3 to 1.0.4
17
index.js
@@ -1,11 +0,8 @@ | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var s = require('./src/store'); | ||
var af = require('./src/actionFactory'); | ||
var d = require('./src/debug'); | ||
__export(require('./src/store')); | ||
__export(require('./src/actionFactory')); | ||
__export(require('./src/helpers')); | ||
exports.bootstrap = (defaultState, renderCallback, debugCallback = undefined, subStateSeparator = '.') => { | ||
import * as s from './src/store'; | ||
import * as af from './src/actionFactory'; | ||
import * as d from './src/debug'; | ||
export * from './src/store'; | ||
export * from './src/actionFactory'; | ||
export * from './src/helpers'; | ||
export let bootstrap = (defaultState, renderCallback, debugCallback = undefined, subStateSeparator = '.') => { | ||
debugCallback && d.bootstrap((m, p) => debugCallback(`fun-model -> ${m}`, p)); | ||
@@ -12,0 +9,0 @@ s.bootstrap(defaultState, subStateSeparator); |
{ | ||
"name": "fun-model", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "fun-model is pure functional implementation of FLUX architecture.", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -1,9 +0,9 @@ | ||
var s = require('./store'); | ||
var d = require('./debug'); | ||
import * as s from './store'; | ||
import * as d from './debug'; | ||
let render = null; | ||
exports.bootstrap = (renderCallback) => { | ||
export let bootstrap = (renderCallback) => { | ||
render = renderCallback; | ||
d.log('Action factory has been initialized.'); | ||
}; | ||
exports.createAction = (cursor, handler) => { | ||
export let createAction = (cursor, handler) => { | ||
return ((params) => { | ||
@@ -20,3 +20,3 @@ validateRenderCallback(); | ||
} | ||
exports.createActions = (...pairs) => { | ||
export let createActions = (...pairs) => { | ||
return ((params) => { | ||
@@ -34,3 +34,3 @@ validateRenderCallback(); | ||
}; | ||
exports.createAsyncAction = (cursor, handler) => { | ||
export let createAsyncAction = (cursor, handler) => { | ||
return ((params) => { | ||
@@ -37,0 +37,0 @@ return new Promise((f, r) => { |
@@ -23,3 +23,3 @@ import * as s from './store'; | ||
validateRenderCallback(); | ||
if (changeState(unifyCursor(cursor, params), handler, params)) { | ||
if (changeState(unifyCursor<TState, TParams>(cursor, params), handler, params)) { | ||
render(); | ||
@@ -60,3 +60,3 @@ d.log('Rendering invoked...'); | ||
validateRenderCallback(); | ||
let c = unifyCursor(cursor, params); | ||
let c = unifyCursor<TState, TParams>(cursor, params); | ||
let oldState = s.getState(c); | ||
@@ -63,0 +63,0 @@ let newState = handler(oldState, params); |
let debug = undefined; | ||
exports.bootstrap = (debugCallback) => { | ||
export let bootstrap = (debugCallback) => { | ||
debug = debugCallback; | ||
}; | ||
function log(message, params) { | ||
export function log(message, params) { | ||
debug && debug(message, params); | ||
} | ||
exports.log = log; |
@@ -1,2 +0,2 @@ | ||
function shallowCopy(source, callback = (t) => { }) { | ||
export function shallowCopy(source, callback = (t) => { }) { | ||
let target = {}; | ||
@@ -9,3 +9,2 @@ for (var property in source) | ||
} | ||
exports.shallowCopy = shallowCopy; | ||
; |
@@ -1,14 +0,14 @@ | ||
var h = require('./helpers'); | ||
var d = require('./debug'); | ||
import * as h from './helpers'; | ||
import * as d from './debug'; | ||
let state = null; | ||
let stateSeparator = '.'; | ||
let rootStateKey = ''; | ||
exports.rootCursor = { | ||
export let rootCursor = { | ||
key: rootStateKey | ||
}; | ||
exports.bootstrap = (defaultState, subStateSeparator = '.') => { | ||
export let bootstrap = (defaultState, subStateSeparator = '.') => { | ||
stateSeparator = subStateSeparator; | ||
state = defaultState; | ||
}; | ||
exports.getState = (cursor) => { | ||
export let getState = (cursor) => { | ||
let getInnerState = (innerState, path) => { | ||
@@ -29,3 +29,3 @@ if (path.length === 0) | ||
}; | ||
exports.setState = (cursor, updatedState) => { | ||
export let setState = (cursor, updatedState) => { | ||
let setInnerState = (innerState, path) => { | ||
@@ -32,0 +32,0 @@ if (path.length === 0) |
171699
371