🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

observable-signal

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

observable-signal

Observable and Signals merged together to support imperative and functional reactive paradigms

0.1.2
latest
Source
npm
Version published
Weekly downloads
1
-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

Observable Signal

A hybrid state manager implementing the Signal and the Observable interfaces to support imperative-reactive and functional-reactive programming paradigms.

Example

import { ObservableSignal } from 'observable-signal';
import { map } from 'rxjs/operators';
import { rml } from 'rimmel';

export const Button = () => {
  const [ state, setState ] = ObservableSignal(0);

  const derivedState = state.pipe(
    map(x => x*2)
  );

  return rml`
    <button onclick="${(e: Event) => setState(state +1)}">Increment</button> 
    <button onclick="${(e: Event) => state.next(0)}">Zero</button>

    <hr>

    Master state: <span>${state}</span><br>
    Derived state: <span>${derivedState}</span><br>
  `;
};

document.body.innerHTML = Button();

Playground

https://stackblitz.com/edit/observable-signal

Keywords

observable-signal

FAQs

Package last updated on 19 May 2024

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