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

rn-watcher

v0.0.1

Published

Simply spy on the bridge using RxJs

Downloads

4

Readme

Build Status Coverage Status License: MIT

Simply spy on the React Native bridge using ReactiveX/RxJs.

This is a fully functional alternative to jondot/rn-snoopy.


rn-watcher


Usage

Installation

$ npm install --save-dev rn-watcher

# or

$ yarn add -D rn-watcher

In your code

Insert that snippet at the top of your application file :

import MessageQueue from 'react-native/Libraries/BatchedBridge/MessageQueue';
import RnWatcher from 'rn-watcher';

const messages$ = RnWatcher.createFrom(MessageQueue);

messages$.subscribe(console.log);

From that point, you're able to see every messages between the JavaScript and the Native realms inside your debugging browser console.

API and configuration

The module comes with a configuration object as second argument :

const configurations = { applyNoFilter: true, batchNumber: 5, batchTime: 1000 };

const messages$ = RnWatcher.createFrom(MessageQueue, configurations);

applyNoFilter

When working with React Native in debugging mode, there are more emitted messages than in production mode. It can be justified by the fact that debugging mode needs extra tools to ensure a good developer experience.

Since this module aims to focus on important messages, it provides a filter on different ones that are debugging related.

For example, rn-watcher excludes messages concerning the WebSocketModule, which aims to provide a websocket connection between the packager and your web browser.

The excluded modules are listed in this file (feel free to open a pull request to add more :blush: )

  • Default value: false
  • Possible values: false | true
  • The output streams receives an Object corresponding to one message

batchNumber

When trying to listen to the bridge using the MessageQueue module, many messages can be emitted. It seems to be a good solution to be able to batch some messages by number before subscribing.

Using the batchNumber key allows to pack messages inside an array of batchNumber elements.

For example :

const messages$ = RnWatcher.createFrom(MessageQueue, { batchNumber: 5 );

messages$
	.subscribe(messages => {
		console.log(messages); // will only be printed when 5 messages have been received
	}):
  • Default value: 0 (streams item one by one, each time it's received)
  • Possible values: any Number
  • The value received by subscription is an Array of Objects with size equals to batchNumber

batchTime

When trying to listen to the bridge using the MessageQueue module, many messages can be emitted. It seems to be a good solution to be able to batch some messages using time intervals.

Using the batchTime allows to pack messages inside array of elements picked within a period.

For example :

const messages$ = RnWatcher.createFrom(MessageQueue, { batchTime: 1000 );

messages$
	.subscribe(messages => {
		console.log(messages); // will only be printed every 1 second
	}):
  • Default value: 0 (streams item one by one, each time it's received)
  • Possible values: any Number (milliseconds)
  • The value received by subscription is an Array of Objects

Using combined configuration

It's possible to combine the three previous configuration :

/**

Messages will be printed every 1 second OR when messages size have reached 5 elements.

We also have removed the filters on default module, so the ones like WebSocketModules will be printed.

*/
const messages$ = RnWatcher.createFrom(MessageQueue, { batchTime: 1000, batchNumber: 5, applyNoFilter: true );

messages$
	.subscribe(messages => {
		console.log(messages); 
	}):