LogoLogo
  • Introduction
  • Intro
    • 🚀Getting Started
    • Key Characteristics
    • Fundamentals
    • Motivation
  • Fundamentals
    • 💾Units
      • BoolUnit
      • NumUnit
      • StringUnit
      • DictUnit
      • ListUnit
      • GenericUnit
    • 🤝Systems
      • AsyncSystem
      • Custom AsyncSystem
    • 🤜Action
    • 📦Cluster
  • 🔨Utilities
    • Stream
    • Selection
  • Integrations
    • Angular
    • React
      • useObservable Hook
      • useUnit Hook
  • 📖Guides
    • Configuration
    • Nesting
    • Events
    • Typings
    • Caching
    • Persistence
    • Immutability
    • Freeze and Mute
    • Development Environment
    • General Guidelines
  • More
    • 👀Examples
    • ✍️Articles
Powered by GitBook
On this page

Was this helpful?

  1. Guides

Events

PreviousNestingNextTypings

Last updated 4 years ago

Was this helpful?

Every fundamental ActiveJS construct has a number of built-in Observable events. You can listen to these events by subscribing to the events$ Observable, a property of every fundamental construct.

, , , and have a common EventReplay event, it is triggered on a successful manual replay when you call the replay() method.

have many Units specific events that let you tap into all the action that's happening on a Unit. Every Unit has some common events like EventUnitDispatch, EventUnitDispatchFail andEventUnitFreeze etc.

and have even more events specific to them, like EventDictUnitSet, EventListUnitPush or EventListUnitPop etc.

See for more details.

Listening to events

const theAction = new Action(); // can also be a Unit, System or Cluster

theAction.events$.subscribe(event => {
    // Action, AsyncSystem and Cluster only have one event
    // so filtering is optional
    if(event instanceof EventReplay) {
        console.log('hey, you got replayed');
    }
});

// dispatch a value
theAction.dispatch('order order');
// this won't trigger any event, only Units emit an event on dispatch 

// replay the value
theAction.replay(); // it'll trigger the EventReplay event
📖
Units
Systems
Action
Cluster
Units
ListUnit
DictUnit
API reference