Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable */
import {Controller} from 'cerebral'
import Home from './modules/Home'
import Admin from './modules/Admin'
import doSomething from './chains/doSomething'
const controller = Controller({
state: {
// You can add some initial state here if you want
foo: 'bar'
},
modules: {
home: Home(),
admin: Admin()
},
signals: {
buttonClicked: doSomething
}
})
export default controller
/* eslint-disable */
import {Controller} from 'cerebral'
import Model from 'cerebral/models/immutable'
import Home from './modules/Home'
import Admin from './modules/Admin'
import doSomething from './chains/doSomething'
const controller = Controller(Model({
// You can add some initial state here if you want
foo: 'bar'
}))
controller.addModules({
home: Home,
admin: Admin
})
controller.addSignals({
buttonClicked: doSomething
})
export default controller
constructor(props) {
super(props)
// The controller will be instantiated for every page change and we only
// add the devtools if we indeed are running in the browser
this.controller = Controller({
devtools:
process.env.NODE_ENV === 'production' || typeof window === 'undefined'
? null
: Devtools({ host: 'localhost:8787' }),
modules: { clock },
stateChanges: props.stateChanges,
})
}
render() {
constructor(props) {
super(props)
// The controller will be instantiated for every page change and we only
// add the devtools if we indeed are running in the browser
this.controller = Controller({
devtools:
process.env.NODE_ENV === 'production' || typeof window === 'undefined'
? null
: Devtools({ host: 'localhost:8787' }),
modules: { clock },
stateChanges: props.stateChanges,
})
}
render() {
import { Controller } from 'cerebral'
import Model from 'cerebral/models/immutable'
const model = Model({})
const controller = Controller(model)
controller.model = model
controller.reset = () => {
model.tree.set({})
model.tree.commit()
}
export default controller
setUp: function (cb) {
var controller = this.controller = Controller(Model({}))
addressbar.value = '/'
this.createRouteTest = function createRouteTest (options) {
if (this.router) {
throw new Error('Router instance must be detached by `tearDown` script. Do not call `createRouteTest` twice inside one test.')
}
var doesMatch = false
var defaultPrevented = false
var routerOptions = options.options || {}
routerOptions.preventAutostart = true
controller.addSignals({
match: {
chain: [ function setMatch () { doesMatch = true } ],
immediate: true
module.exports['should work in node.js'] = function (test) {
var controller = Controller(Model({}))
controller.addSignals({
'test': {
chain: [ function checkAction (input) { test.ok(true) } ],
immediate: true
}
})
controller.addModules({
router: Router({
'/test': 'test'
})
})
var router = controller.getServices().router
router.trigger()
var Factory = function (state, defaultArgs) {
var eventEmitter = new EventEmitter();
var initialState = Store(state);
state = initialState;
var controller = cerebral.Controller({
defaultArgs: defaultArgs,
onReset: function () {
state = initialState;
},
onGetRecordingState: function () {
return state.export();
},
onSeek: function (seek, isPlaying, currentRecording) {
state = state.import(currentRecording.initialState);
eventEmitter.emit('change', state);
},
onUpdate: function () {
eventEmitter.emit('change', state);
},
onRemember: function () {
eventEmitter.emit('remember', state);
apps: ports.reduce((apps, port) => {
apps[port] = Object.assign(storedApps[port], {
controller: Controller(
app({
port,
type: storedApps[port].type,
ssl: storedApps[port].ssl,
})
),
})
return apps
}, {}),
currentPort: currentPort || ports[0] || null,
import React from 'react'
import {render} from 'react-dom'
import {Controller} from 'cerebral'
import {Container} from 'cerebral/react'
import Devtools from 'cerebral/devtools'
import App from './components/App'
const controller = Controller({
devtools: Devtools(),
state: {
title: 'Hello from Cerebral!'
}
})
render((
), document.querySelector('#root'))