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 🙏

© 2026 – Pkg Stats / Ryan Hefner

miracle-observer

v0.1.0

Published

Push-based Data & Event management based on React Hooks and RxJS

Readme

miracle-observer

Push-based Data & Event management based on React Hooks and RxJS

Install

npm i miracle-observer

https://www.npmjs.com/package/miracle-observer

Usage

// init store all in one file or multifiles
initStore({
  theme: 'night',
  language: 'zh'
});

initStore({
  userName: 'K68',
  role: 'admin'
}, 'account');

initStore({
  react: '16',
  rxjs: '6'
}, 'dependencies');

// create notify instance, you can have multi stations in anywhere
const station = createNotifyStation((k, v, store) => {
  // example
  store[k] = v;
}, SubscribeMatchType.ExactMatch | SubscribeMatchType.ContainsNotify);

const sub1 = subscribe('hello_world', (k, v, store) => {
  console.log(k, store[k]);
  console.log('sub1 result: ', v === store[k]);
});

/**
 * 订阅方法
 * @param key           Event Key
 * @param cbGetState    Callback
 * @param matchType     SubscribeMatchType
 * @param period        time that has to pass before emiting new items (ms)
 * @param throttle      0 for throttleTime
 *                      1 for debounceTime
 * @param preprocessing data pre process
**/

const sub2 = subscribe('goodbye', (k, v, store) => {
  console.log(k, store[k]);
  console.log('sub2 result: ', v === store[k]);
  console.log(JSON.stringify(store));
}, SubscribeMatchType.ContainsNotify);

station.notify('hello_world', ': our future');
station.notify('bye', ': ContainsNotify');

setTimeout(() => {
  sub1.unsubscribe();
  sub2.unsubscribe();
  shutdown();
}, 1000);

Use with React Hook

import React, {useState} from 'react';
import {
  useMiracleObserver,
  useMiracleObserverHot,
  createNotifyStation,
  SubscribeMatchType,
} from 'miracle-observer';

const App: () => React$Node = () => {
  const [globalCount, setGlobalCount] = useState(0);

// bind every rerender, globalCount is fresh
  useMiracleObserverHot(
    'actionOne.actionTwo.actionThree',
    (key, value, store) => {
      console.log(key + value + globalCount);
      setCount(count + 1);
    },
    SubscribeMatchType.ContainsNotify,
  );

// bind once in Component Mount, globalCount will not change
  useMiracleObserver(
    'actionTwo',
    (key, value, store) => {
      console.log(key + value + globalCount);
      // setGlobalCount(store.globalCount);
      setGlobalCount(gCount => gCount + 1);
    },
    SubscribeMatchType.ExactMatch,
    2000,
    0,
  );

  ...

Use with Ajax

npm install axios

axios.get('https://www.so.com')
  .then((response) => {
    station.notify('hello_world', response.data);

  }).catch((error) => {
    console.log(error.toJSON());
  });

Reference

https://github.com/ReactiveX/RxJS

https://reactjs.org/docs/hooks-effect.html

https://cn.rx.js.org/manual/index.html

https://cn.rx.js.org/class/es6/Observable.js~Observable.html

https://medium.com/@thomasburlesonIA/https-medium-com-thomasburlesonia-react-hooks-rxjs-facades-4e116330bbe1

https://www.jianshu.com/p/76901410645a

https://github.com/LeetCode-OpenSource/rxjs-hooks

https://github.com/LeetCode-OpenSource/rxjs-hooks

https://zhuanlan.zhihu.com/p/49408348

https://github.com/react-native-community/hooks

https://www.cnblogs.com/chenwenhao/p/12639077.html

https://segmentfault.com/a/1190000018253310