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

react-hardware

v0.5.0-alpha.2

Published

React firmata bindings.

Downloads

6

Readme

React Hardware

Build Status

You are on the rewrite branch of an alpha software project. That should tell you something about what to expect happening here. :)

React Hardware enables you to build firmata-based hardware applications using a consistent developer experience based on JavaScript and React. The focus of React Hardware is on developer efficiency across all the platforms you care about - learn once, write anywhere.

React Hardware is a IoT and Robotics programming framework developed by Dustan Kasten. Being based on firmata, it is capable of providing feature parity with alternative tools such as Johnny-Five.

Note that this is currently alpha software and hasn’t been tested or have many features implemented. It currently supports firmata’s digitalWrite and analogWrite methods. Full support for firmata is coming including an event system to receive feedback from the board and manipulate state as a result of that.

Hello World

The "Hello World" program of microcontrollers is to "blink an LED". The following code demonstrates how this is done naively with React Hardware and how React’s programming model brings composability to the hardware world.

import React from 'react';
import ReactHardware, {Led} from 'react-hardware';

const HIGH = 255;
const LOW = 0;

class Application extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      value: 0,
      _timer: null,
    };
  }

  componentDidMount() {
    this.state._timer = setInterval(_ => (
      this.setState({value: this.state.value === HIGH ? LOW : HIGH})
    ), this.props.interval);
  }

  render() {
    return (
      <Led pin={10} value={this.state.value} />
    );
  }
}

var PORT = '/dev/tty.usbmodem1411';
ReactHardare.render(<Application />, PORT);

While this is unquestionably more code than it’s Johnny-Five or Sketch equivalents, this now gives you the ability to extract the parts of your board into self-contained components and compose these together. In this application we introduced the concept of a flashing LED, hard-coded naively into the global state. Let’s now extract the idea of a flashing LED into something we can share with our team or even on npm.

import React from 'react';
import ReactHardware, {Board, Led} from 'react-hardware';

const HIGH = 255;
const LOW = 0;

class FlashingLed extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      value: 0,
      _timer: null,
    };
  }

  componentDidMount() {
    this.state._timer = setInterval(_ => (
      this.setState({value: this.state.value === HIGH ? LOW : HIGH})
    ), this.props.interval);
  }

  render() {
    return (
      <Led {...this.props} value={this.state.value} />
    );
  }
}

class Application extends React.Component {
  render() {
    return (
      <Board>
        <FlashingLed pin={9} />
        <FlashingLed pin={10} />
        <FlashingLed pin={11} />
        <FlashingLed pin={12} />
      </Board>
    );
  }
}

var PORT = '/dev/tty.usbmodem1411';
ReactHardware.render(<Application />, PORT);

Community

There should be #react-hardware channels created on both https://reactiflux.com/ and IRC.

Contributing

The codebase is written in es6 with (sporadic) types and compiled with babel. Follow the existing style when creating changes. Eslint and the flow type checker will be set up shortly. While the project is under heavy active development it would be useful to make an issue discussing your change before making a PR to ensure we aren’t duplicating effort.

License

Copyright (c) 2015 Dustan Kasten | [email protected] Licensed under the MIT license.