Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@storeon/angular

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storeon/angular

Storeon for Angular 🅰⚡

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
285
decreased by-8.36%
Maintainers
2
Weekly downloads
 
Created
Source

@storeon/angular

Storeon logo by Anton Lovchikov

A tiny event-based Redux-like state manager Storeon for Angular.

Online Demo | Demo with Angular Ivy

It is just 533 bytes (minified and gzipped) Angular module. It uses Size Limit to control size.

Read more about Storeon article.


How to use

import * as createStore from 'storeon'
import * as devTools from 'storeon/devtools';

export interface State {
  count: number
}

// Initial state, reducers and business logic are packed in independent modules
let increment = (store: createStore.Store<State>) => {
  // Initial state
  store.on('@init', () => ({ count: 0 }))
  // Reducers returns only changed part of the state
  store.on('inc', ({ count }) => ({ count: count + 1 }))
}

export const store = createStore([increment, !environment.production && devTools])

// your NgModule

import { NgStoreonModule, STOREON } from '@storeon/angular';

@NgModule({
  imports: [NgStoreonModule], // NgStoreonModule
  ...
  providers: [{
    provide: STOREON,
    useValue: store  // your store
  }],
  ...
// your component

import { Component, OnInit } from '@angular/core';
import { NgStoreonService } from '@storeon/angular';
import { State } from './app.module';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
  changes: Observable<number>;
  constructor(private ngstoreon: NgStoreonService<State>) { }
  title = 'storeon-angular';

  ngOnInit() {
    this.changes = this.ngstoreon.useStoreon('count');
  }

  updateState() {
    this.ngstoreon.dispatch('inc');
  }
}

Keywords

FAQs

Package last updated on 25 May 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc