@jhoguet/rxjs-debugger

0.0.3 • Public • Published

#rxjs-debugger

Use with caution, this is still in the proof of concept phase and lacks adequate testing both in automated tests and in the wild.

Intent

The intent of this repo is to make it easier to debug streams in a running application.

Some of the driving goals are:

  1. You should not need to install any special tools / chrome extensions to debug the app
  2. You should not need to restart the app / put it into debug mode
  3. Debugging should do as little as possible until something asks for the debug info (delay as much as possible)
  4. Debugging should not be able to break the app
  5. You should be able to use the debugger to change state

Getting Started

npm i @jhoguet/rxjs-debugger

then in your index file

import { extendObservable } from '@jhoguet/rxjs-debugger';
import { Observable } from 'rxjs';

extendObservable(Observable);

// now can add debug points to any stream or get a debugger... see api below

Next Steps / How to help

  • explore options other than extending the Observable prototype, eg bind aka :: or a global getDebugger(forStream) instead of forStream.getDebugger()
  • research the risk of .source, is this a non-starter? are there better options?
  • catch up on todos
  • companion UI library for visualizing the stream
  • refactor to embrace fact that a subscription should be more first class than stream is, and that a subscription relies on 0 to many subscriptions (eg combineLatest and other aggregators)
  • refactor tests in debugOperator.tests.js to be index.tests.js
  • address memory leaks (eg in SubscriptionDebugger)

Stream Api

On any observable, there is now a debug operator.

###stream.debug(name :string, description :string)

name description
name the name for this debug point in the stream
description a description to describe the value at this point in the stream

stream.getDebugger(name :?string) :StreamDebugger

This will return the closest StreamDebugger to the stream.

StreamDebugger

debugger.nextUpstream(name :?string)

debugger.nextDownstream(name :?string)

You cannot go further downstream than the original stream on which .getDebugger() was called

debugger.getSubscriptions()

SubscriptionDebugger

debugger.trace()

returns an array of TimestampedValues for the most recent subscription for each debug in the observable stream.

debugger.setValue(value)

sets the value on observable

StreamDebuggerApi

api.getDebugger(stream :Observable, name :?string)

Next Steps / How to help

  • explore options other than extending the Observable prototype, eg bind aka :: or a global getDebugger(forStream) instead of forStream.getDebugger()
  • research the risk of .source, is this a non-starter? are there better options?
  • likely missing some documentation, what is missing? where is more depth needed?

Readme

Keywords

none

Package Sidebar

Install

npm i @jhoguet/rxjs-debugger

Weekly Downloads

1

Version

0.0.3

License

MIT

Last publish

Collaborators

  • jhoguet