Created
January 27, 2021 15:45
-
-
Save luistak/e3cb74c500f5804f3d2c80b796448fcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Observable } from 'windowed-observable'; | |
// Define a specific context namespace | |
const observable = new Observable('cart-items'); | |
const observer = (item) => console.log(item); | |
// Add an observer subscribing to new events on this observable | |
observable.subscribe(observer) | |
// Unsubscribing | |
observable.unsubscribe(observer); | |
... | |
// On the publisher part of the app | |
const observable = new Observable('cart-items'); | |
observable.publish({ id: 1234, name: 'Mouse Gamer XyZ', quantity: 1 }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment