cape-firebase
Advanced tools
Comparing version 0.4.2 to 0.5.0
@@ -27,4 +27,3 @@ 'use strict'; | ||
exports.handleProfileField = handleProfileField; | ||
exports.handleEntityPut = handleEntityPut; | ||
exports.handleEntityUpdate = handleEntityUpdate; | ||
exports.sendPayload = sendPayload; | ||
exports.handleTriplePut = handleTriplePut; | ||
@@ -83,11 +82,14 @@ | ||
var handleFieldSubmit = exports.handleFieldSubmit = (0, _cond3.default)([[isWatchedEntity, handleProfileField], [_stubTrue3.default, _util.nextAction]]); | ||
function handleEntityPut(_ref4) { | ||
var firebase = _ref4.firebase, | ||
action = _ref4.action, | ||
next = _ref4.next; | ||
function sendPayload(handler) { | ||
return function (_ref4) { | ||
var action = _ref4.action, | ||
firebase = _ref4.firebase, | ||
next = _ref4.next; | ||
next(action); | ||
return (0, _util.entitySet)(firebase, action.payload); | ||
next(action); | ||
return handler(firebase, action.payload); | ||
}; | ||
} | ||
function handleEntityUpdate(_ref5) { | ||
function handleTriplePut(_ref5) { | ||
var firebase = _ref5.firebase, | ||
@@ -98,11 +100,3 @@ action = _ref5.action, | ||
next(action); | ||
return (0, _util.entityUpdate)(firebase, action.payload); | ||
} | ||
function handleTriplePut(_ref6) { | ||
var firebase = _ref6.firebase, | ||
action = _ref6.action, | ||
next = _ref6.next; | ||
next(action); | ||
return (0, _util.triplePut)(firebase, action); | ||
} |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.uploadFile = exports.UPLOAD_FILE = exports.saveTriple = exports.SAVE_TRIPLE = exports.updateEntity = exports.UPDATE_ENTITY = exports.saveEntity = exports.SAVE_ENTITY = exports.logout = exports.LOGOUT = exports.auth = exports.AUTH = undefined; | ||
exports.uploadFile = exports.UPLOAD_FILE = exports.saveTriple = exports.SAVE_TRIPLE = exports.updateEntity = exports.UPDATE_ENTITY = exports.saveEntity = exports.SAVE_ENTITY = exports.logout = exports.LOGOUT = exports.deleteTriple = exports.DELETE_TRIPLE = exports.deleteEntity = exports.DELETE_ENTITY = exports.auth = exports.AUTH = undefined; | ||
@@ -26,2 +26,8 @@ var _nthArg2 = require('lodash/nthArg'); | ||
var DELETE_ENTITY = exports.DELETE_ENTITY = 'fire/DELETE_ENTITY'; | ||
var deleteEntity = exports.deleteEntity = (0, _capeRedux.createSimpleAction)(DELETE_ENTITY, _identity3.default, (0, _nthArg3.default)(1)); | ||
var DELETE_TRIPLE = exports.DELETE_TRIPLE = 'fire/DELETE_TRIPLE'; | ||
var deleteTriple = exports.deleteTriple = (0, _capeRedux.createSimpleAction)(DELETE_TRIPLE, _identity3.default, (0, _nthArg3.default)(1)); | ||
var LOGOUT = exports.LOGOUT = 'fire/LOGOUT'; | ||
@@ -28,0 +34,0 @@ var logout = exports.logout = (0, _capeRedux.noopAction)(LOGOUT); |
@@ -30,3 +30,3 @@ 'use strict'; | ||
var dispatcher = exports.dispatcher = (_dispatcher = {}, _defineProperty(_dispatcher, _actions.AUTH, _actionHandlers.handleAuth), _defineProperty(_dispatcher, _actions.LOGOUT, _actionHandlers.handleLogout), _defineProperty(_dispatcher, _actions.SAVE_ENTITY, _actionHandlers.handleEntityPut), _defineProperty(_dispatcher, _actions.SAVE_TRIPLE, _actionHandlers.handleTriplePut), _defineProperty(_dispatcher, _reduxField.SUBMIT, _actionHandlers.handleFieldSubmit), _defineProperty(_dispatcher, _actions.UPDATE_ENTITY, _actionHandlers.handleEntityUpdate), _dispatcher); | ||
var dispatcher = exports.dispatcher = (_dispatcher = {}, _defineProperty(_dispatcher, _actions.AUTH, _actionHandlers.handleAuth), _defineProperty(_dispatcher, _actions.DELETE_ENTITY, (0, _actionHandlers.sendPayload)(_util.entityDelete)), _defineProperty(_dispatcher, _actions.DELETE_TRIPLE, (0, _actionHandlers.sendPayload)(_util.tripleDelete)), _defineProperty(_dispatcher, _actions.LOGOUT, _actionHandlers.handleLogout), _defineProperty(_dispatcher, _actions.SAVE_ENTITY, (0, _actionHandlers.sendPayload)(_util.entitySet)), _defineProperty(_dispatcher, _actions.SAVE_TRIPLE, _actionHandlers.handleTriplePut), _defineProperty(_dispatcher, _reduxField.SUBMIT, _actionHandlers.handleFieldSubmit), _defineProperty(_dispatcher, _actions.UPDATE_ENTITY, (0, _actionHandlers.sendPayload)(_util.entityUpdate)), _dispatcher); | ||
@@ -33,0 +33,0 @@ function fireMiddleware(firebase, entities) { |
@@ -50,5 +50,7 @@ 'use strict'; | ||
exports.nextAction = nextAction; | ||
exports.entityDelete = entityDelete; | ||
exports.entitySet = entitySet; | ||
exports.entityUpdate = entityUpdate; | ||
exports.getTriplePath = getTriplePath; | ||
exports.tripleDelete = tripleDelete; | ||
exports.triplePut = triplePut; | ||
@@ -108,3 +110,5 @@ exports.arrayTrueObj = arrayTrueObj; | ||
} | ||
function entityDelete(firebase, item) { | ||
return entityDb(firebase.entity, item).set(null); | ||
} | ||
function entitySet(firebase, node) { | ||
@@ -133,12 +137,21 @@ var entity = firebase.entity, | ||
} | ||
function tripleDelete(_ref2, payload) { | ||
var entity = _ref2.entity, | ||
TIMESTAMP = _ref2.TIMESTAMP; | ||
var subject = payload.subject, | ||
predicate = payload.predicate, | ||
object = payload.object, | ||
single = payload.single; | ||
return entity.child(getTriplePath(subject, predicate, object, single)).set(null); | ||
} | ||
// Use action instead of calling this directly. | ||
// Save refs to subject. | ||
function triplePut(_ref2, _ref3) { | ||
function triplePut(_ref3, _ref4) { | ||
var _updateObj; | ||
var entity = _ref2.entity, | ||
TIMESTAMP = _ref2.TIMESTAMP; | ||
var payload = _ref3.payload, | ||
meta = _ref3.meta; | ||
var entity = _ref3.entity, | ||
TIMESTAMP = _ref3.TIMESTAMP; | ||
var payload = _ref4.payload, | ||
meta = _ref4.meta; | ||
@@ -145,0 +158,0 @@ // Payload needs to be a have triple style object props. |
{ | ||
"name": "cape-firebase", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"description": "Help integrate CAPE redux projects with Firebase.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
118506
469