router5
  • Read Me
  • Introduction
    • Why router5?
    • Getting Started
    • Ecosystem
    • Core concepts
    • Transition phase
  • Guides
    • Defining routes
    • Path Syntax
    • Router options
    • Navigating
    • In the browser
    • Observing state
  • Integration
    • With React
    • With Redux
  • Advanced
    • Plugins
    • Middleware
    • Preventing navigation
    • Errors and redirections
    • Dependency injection
    • Loading async data
    • Universal routing
    • Listeners plugin
  • API Reference
  • Migration
    • Migrating from 7.x to 8.x
    • Migrating from 6.x to 7.x
    • Migrating from 5.x to 6.x
    • Migrating from 4.x to 5.x
    • Migrating from 3.x to 4.x
    • Migrating from 2.x to 3.x
    • Migrating from 1.x to 2.x
    • Migrating from 0.x to 1.x
Powered by GitBook
On this page
  • Subscribing to state changes
  • Observing state changes
  1. Guides

Observing state

From router5@6.1.0 and onwards, your router instance is compatible with most observable libraries.

Subscribing to state changes

You can subscribe to route changes using router.subscribe(), and will receive an object containing route and previousRoute.

Observing state changes

Router instances are observables. You can use most stream libraries out there and create a stream from your router instance:

  • RxJS (Rx.Observable.from(router))

  • xstream (xs.fromObservable(router))

  • most (most.from(router))

  • etc...

PreviousIn the browserNextIntegration

Last updated 6 years ago