var rebuild = function () { href(function (link) {router(link)}) if (entry.repo) { return actions.submitBuild(entry.repo)(dx) } if (entry.build) { return actions.submitBuild(entry.build.repository)(dx) } }
[INIT]: (_, sources) => { const effectActions = Pushable(function onClose (error) { // cleanup href and/or history console.error(error) }) // enable catching <href a=""></href> links href(push) // enable HTML5 history API history(push) return effectActions function push (href) { effectActions.push({ type: SET, payload: href }) } },
function init () { const dispatch = sendAction({ onaction: handleAction, onchange: handleChange, state: _state }) href(function (location) { const newState = Object.assign({}, _state, { location }) handleChange(undefined, newState, _state) }) function handleAction (action, state) { const func = dotProp.get(_dataFlow, action.type) const [modelName, actionOrReducer, _func] = action.type.split('.') if (actionOrReducer === 'actions') { return func(action, state, dispatch) } else if (actionOrReducer === 'reducers') { const mutatedState = {} mutatedState[modelName] = func(action, state, dispatch) const newState = Object.assign({}, state, mutatedState) return newState } } function handleChange (action, state, prevState) { if (state === prevState) return const oldTree = document.getElementById('naka-root') const newTree = _router(state.location, state, dispatch) newTree.setAttribute('id', 'naka-root') yo.update(oldTree, newTree) } _state.location = window.location.pathname document .getElementById('naka-root') .appendChild(_router(window.location.pathname, _state, dispatch)) }
run: (effect, sources) => { if (effect !== 'INIT_ROUTER') { return } const effectActions = Pushable(function onClose (error) { // cleanup href and/or history console.error(error) }) // enable catching <href a=""></href> links href(push) // enable HTML5 history API history(push) return effectActions function push (href) { effectActions.push({ type: 'SET_LOCATION', payload: href }) } }
const setLocationStream = () => { const routeActions = Pushable(function onClose (error) { // TODO: clean href and/or history debug('error: ', error) }) function push (href) { debug('push - href: ', href) const pathname = parseUrl(href).pathname routeActions.push(setLocation({ href: href })) if (inputsMap[pathname]) { routeActions.push(inputLoaded({ inputId: inputsMap[pathname]})) } } href(push) history(push) debug('routeActions: ', routeActions) return routeActions }
function onclick () { href(function (link) {router(link)}) }
link.onclick = function () { href(function (link) {router(link)}) }