@hoda5/tracker

[![Build Status](https://semaphoreci.com/api/v1/hoda5/tracker/branches/master/badge.svg)](https://semaphoreci.com/hoda5/tracker) [![codecov](https://codecov.io/gh/hoda5/tracker/branch/master/graph/badge.svg)](https://codecov.io/gh/hoda5/tracker)

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
05May 28, 2021Apr 2, 2018Minified + gzip package size for @hoda5/tracker in KB

Readme

tracker (from Meteor)

Build Status codecov

This package is an adaptation from

npm install @hoda5/tracker
import { autorun, Dependency } from '@hoda5/tracker'

let weather = 'sunny';
const weatherDep = new Dependency;

function getWeather() {
  weatherDep.depend();
  return weather;
}

function setWeather(newWeather) {
  weather = newWeather;
  weatherDep.changed();
}

tracking with console.log

autorun( ()=> {
  const weather = getWeather();
  console.log("Weather: " + weather);
});

setTimeout( () => setWeather("rainy"), 1000);
setTimeout( () => setWeather("cloudy"), 2000);

tracking with ReactJS


const ReactiveComponent = weatherDep.rx(() => {
  const weather = getWeather();
  return (
    <span>
      Weather: <b>{weather}</b>
    </span>
  );
});

const rootElement = document.getElementById("root");
ReactDOM.render(<ReactiveComponent />, rootElement);

setTimeout( () => setWeather("rainy"), 1000);
setTimeout( () => setWeather("cloudy"), 2000);

Edit mynz7nlmwj

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.