npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rxjs-browser-debugger

v0.1.1

Published

RXJS browser debugger is a debug tool that visualizes rxjs observable emissions and other events in a marble diagram.

Downloads

9

Readme

RXJS browser debugger

RXJS browser debugger is a debug tool that visualizes rxjs observable emissions and other events in a marble diagram.

Requirements

  • As the name suggests, the tool only works when the code is executed in a browser. It does not work in a server environment.
  • The tool opens a pop-up window, so the browser should be configured not to block them.
  • rxjs must be version 7.3.0 or higher.

Installation

npm install --save-dev rxjs-browser-debugger

Getting started

To track emissions and other events, use the debug operator in an observable pipe:

import { debug } from 'rxjs-browser-debugger';

target$ = source$.pipe(
  debug('before map'),
  map(x => 2*x)
);

This creates a debug observer that registers all emissions and other events that occur right before the map operator. When target$ has been subscribed to, a pop-up window will open showing the marble diagram of the debug observer.

The debug operator

syntax

  • debug()
  • debug(description)
  • debug(description, shouldDebug)

description: string

Default value: ''

A description to be used for the debug observer. Although optional, it is highly recommended to set this, so that it is immediately clear where emissions and other events originate from.

shouldDebug: (subscriptionIndex: number) => boolean

Default value: () => true

A function that returns a boolean whether a subscription should be added to the marble diagram. This function takes the subscription index as parameter, which starts with 0 and increments after every new subscription. This parameter is useful to control what subscriptions should be included in the marble diagram.

The debug tool application window

Opening the window

The debug window will be opened in the following situations

  1. When any debug observer registers an emission or other event.
  2. When openRxjsBrowserDebugger() is executed in the browser console. Note that the debug operator must be imported at least once in order for this to work.

Explanation of the window

Screenshot with numbers

  1. Menu to configure how the debug observers should be sorted.
  2. Filter menu. This menu is only visible when the user hides a debug observer (see 5) and can be used to show the debug observer again.
  3. Recording button. Click to toggle between pause and record. When paused, emissions and other events will not be recorded and thus not be displayed in the marble diagram. Warning: this also means that emissions and other events will not cause to open the window if it has been closed later. To open the window, openRxjsBrowserDebugger() must be executed in the browser console as explained earlier.
  4. Clear button that clears all emissions and other events visible in the marble diagram and hidden in the filter.
  5. Information about the debug observer. Top title contains the description provided in the debug operator. The debug observers and their tracked subscriptions are numbered. The label on the bottom-left can be clicked to hide the debug observer from view. It can be shown again using the filter menu (see 2). The icon on the bottom-right indicates the status of the subscription (pending, complete, error, or unsubscribed).
  6. Marble indicating an error. Hover to see tooltip with error message if applicable. Click to log the error to the console of the parent window.
  7. Marble indicating a subscription.
  8. Marbles indicating an emitted value. Hover to see tooltip with string value. Click to log the value to the console of the parent window.
  9. Marble indicating a completion.
  10. Marble indicating an unsubscription.

Note: all marbles are ordered in time from left to right. Emissions and other events that are immediately scheduled from each other, either synchronously or asynchronously, are grouped together.

License

Copyright 2024, Kevin Choi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.