-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added lib folder used as entry point
- Loading branch information
Jeroen van der Heijden
committed
Jul 17, 2018
1 parent
ec9085c
commit 845eae4
Showing
19 changed files
with
2,727 additions
and
692 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
>WARNING: This `lib` folder is generated with `npm run babel` and should not be modified! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,71 @@ | ||
/* global process */ | ||
import invariant from 'fbjs/lib/invariant'; | ||
|
||
class Actions { | ||
constructor(names) { | ||
this._callbacks = names.reduce((o, action) => { | ||
typeof action !== 'string' || !action.length || action.charAt(0) === '_' ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot use action `%s`. Each action must be a sting with at least one character and cannot start with an underscore.', action) : invariant(false) : undefined; | ||
this.hasOwnProperty(action) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Action `%s` is already set (duplicate actions are not allowed).', action) : invariant(false) : undefined; | ||
let onKey = `on${action.charAt(0).toUpperCase()}${action.substr(1)}`; | ||
this[action] = (...args) => this._on(onKey, args); | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createActions = exports.Actions = undefined; | ||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* global process */ | ||
|
||
|
||
var _invariant = require('fbjs/lib/invariant'); | ||
|
||
var _invariant2 = _interopRequireDefault(_invariant); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
var Actions = function () { | ||
function Actions(names) { | ||
var _this = this; | ||
|
||
_classCallCheck(this, Actions); | ||
|
||
this._callbacks = names.reduce(function (o, action) { | ||
typeof action !== 'string' || !action.length || action.charAt(0) === '_' ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, 'Cannot use action `%s`. Each action must be a sting with at least one character and cannot start with an underscore.', action) : (0, _invariant2.default)(false) : undefined; | ||
_this.hasOwnProperty(action) ? process.env.NODE_ENV !== 'production' ? (0, _invariant2.default)(false, 'Action `%s` is already set (duplicate actions are not allowed).', action) : (0, _invariant2.default)(false) : undefined; | ||
var onKey = 'on' + action.charAt(0).toUpperCase() + action.substr(1); | ||
_this[action] = function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
|
||
return _this._on(onKey, args); | ||
}; | ||
o[onKey] = []; | ||
return o; | ||
}, {}); | ||
} | ||
|
||
_on(onKey, payload) { | ||
this._callbacks[onKey].forEach(cb => cb(...payload)); | ||
} | ||
|
||
_addStore(store) { | ||
for (let onKey in this._callbacks) { | ||
if (typeof store[onKey] === 'function') { | ||
this._callbacks[onKey].push(store[onKey].bind(store)); | ||
} else if (process.env.NODE_ENV !== 'production') { | ||
window.console.warn('Store `%s` is missing function `%s` (action will be ignored).', store.constructor.name, onKey); | ||
_createClass(Actions, [{ | ||
key: '_on', | ||
value: function _on(onKey, payload) { | ||
this._callbacks[onKey].forEach(function (cb) { | ||
return cb.apply(undefined, _toConsumableArray(payload)); | ||
}); | ||
} | ||
}, { | ||
key: '_addStore', | ||
value: function _addStore(store) { | ||
for (var onKey in this._callbacks) { | ||
if (typeof store[onKey] === 'function') { | ||
this._callbacks[onKey].push(store[onKey].bind(store)); | ||
} else if (process.env.NODE_ENV !== 'production') { | ||
window.console.warn('Store `%s` is missing function `%s` (action will be ignored).', store.constructor.name, onKey); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}]); | ||
|
||
return Actions; | ||
}(); | ||
|
||
const createActions = (names) => new Actions(names); | ||
var createActions = function createActions(names) { | ||
return new Actions(names); | ||
}; | ||
|
||
export {Actions, createActions}; | ||
exports.Actions = Actions; | ||
exports.createActions = createActions; |
Oops, something went wrong.