
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
cerebral-angular-immutable-store
Advanced tools
A cerebral package for angular and immutable-store
You can download the Chrome Cerebral Debugger here.
Cerebral main repo is located here and a video demonstration can be found here.
npm install cerebral-angular-immutable-store
or
bower install cerebral-angular-immutable-store
The way you structure a Cerebral Angular app works quite differently. Instead of creating services and controllers that handles your application state you use signals. Signals are a way to handle application flow that gives you a much better overview, a set structure and it can be debugged.
The examples below is just one way of organizing these signals and their actions. Feel free to explore your own ways of doing so.
We are going to use a file structure where we use main.js, run.js and config.js
main.js
import config from './config.js';
angular.module('app', ['cerebral'])
.config(config)
config.js
export default function (cerebralProvider) {
// Sets default arguments passed to all signals
cerebralProvider.setDefaultArgs({
foo: 'bar'
});
// Sets the initial state of the app. Put all the state of the
// application in here
cerebralProvider.setState({
list: ['foo']
});
};
Read more about immutable-store to understand how mapping of state works.
Creating actions are generic. It works the same way across all packages. Please read about actions at the Cerebral Repo - Actions. You can also watch a video on signals to get an overview of how it works.
In larger application you should consider putting each action in its own file.
run.js
import {
setLoading,
saveForm,
unsetLoading
} from './actions.js';
export default function (cerebral) {
// The saveForm action runs async because it is in an array. You can have multiple
// actions in one array that runs async in parallel.
controller.signal('formSubmitted', setLoading, [saveForm], unsetLoading);
};
main.js
import config from './config.js';
import run from './run.js';
angular.module('app', ['cerebral'])
.config(config)
.run(run);
The default args also includes default services from Angular.
const someAction = function someAction (args, state) {
args.services.$http // Do server fetching etc.
};
components/MyComponent.js
export default function () {
return {
controllerAs: 'myComponent',
scope: {},
templateUrl: 'myComponent.html',
controller: function ($scope, cerebral) {
// Trigger signals
$scope.addItemClicked = function () {
cerebral.signals.addItemClicked({
item: 'foo'
});
};
}
};
};
When running the application you need to grab the initial state of the application. You can do this with the exposed "get" method.
components/MyComponent.js
export default function () {
return {
controllerAs: 'myComponent',
scope: {},
templateUrl: 'myComponent.html',
controller: function ($scope, cerebral) {
// Adds a "list" prop to the $scope which
// will automatically update when the list
// updates
cerebral.injectState($scope, {
list: ['list']
});
// Trigger signals
$scope.addItemClicked = function () {
cerebral.signals.addItemClicked({
item: 'foo'
});
};
}
};
};
With the Cerebral controller you can record and replay state changes.
components/MyComponent.js
export default function () {
return {
controllerAs: 'myComponent',
scope: {},
templateUrl: 'myComponent.html',
controller: function ($scope, cerebral) {
// Start recording by passing the initial state of the recording
cerebral.recorder.record(controller.get());
// Stop recording
cerebral.recorder.stop();
// Seek to specific time and optionally start playback
cerebral.recorder.seek(0, true);
}
};
};
npm installnpm startlocalhost:8080FAQs
A Cerebral package for angular and immutable store
We found that cerebral-angular-immutable-store demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.