Skip to content

Latest commit

 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Radio

Messenger tool for typescript. It is inspired on Redux.

API

Radio::subscribe

Registers a listener by id. Many supscriptors are allowed.

Radio::dispatch

Sends the message to the subscriptions by id.

uuid

The null uuid value;

Id

Generates a new uuid to avoid colisions in the store.

Usage

On a project generated with angular-cli

Install

npm install https://github.com/MoNoApps/radio.git

Import

Register Radio provider (DI)

import { Component, OnInit } from '@angular/core';
import { Radio, Id } from '@monoapps/radio';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
  providers: [Radio]
})
export class AppComponent implements OnInit {
  title = 'app works!';

  constructor(private radio: Radio) { }

  ngOnInit() {
    this.radio.subscribe(Id, this.print);
  }

  print(value) {
    console.log(value);
  }
}

Import Radio from the registered module

import { Component, OnInit } from '@angular/core';
import { Radio, Id } from '@monoapps/radio';

export class SelectComponent implements OnInit {

  constructor(private radio: Radio) { }

  ngOnInit() {
    this.radio.dispatch(Id, ['message']);
  }
  
}

About

Radio with listener stores

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages