Skip to content

feat(router): Expose observable through public property/method #5457

@brandonroberts

Description

@brandonroberts

Currently, the router uses an ObservableWrapper to allow subscribing to URL updates. I want access to the private _subject property to access the observable directly. The use case is using a Redux store to manage application state that allows us to capture the current URL of the router after navigation. This combined with the Redux dev tools would allow the router to be used to navigate back to previous URLs and the states associated with the URL at that point in time. Sample code with the current workaround below.

const routerObservable = <Observable<string>>router['_subject'];

routerObservable
  .filter(url => url !== this.currentUrl)
  .subscribe((url: string) => {
    if (url !== this.lastUrl) {
      state.dispatch(route.navigate({ url }));
    }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions