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

r-js

v0.3.0

Published

An application framework using functional reactive concepts and virtual-dom

Downloads

14

Readme

R

A view concept for Functional Reactive Applications. Read the following article for an introduction: Functional Reactive Applications.

Supports

API

R exposes a simple API to give your FRP code a view layer to hook on to.

DOM

DOM has to be available in the scope of the module. It is used by the JSX transpiler. So, whenever you write JSX, import the DOM function.

Component

A component has to return an observable of vritual dom structures.

import {Component, DOM} from 'r-js';

exports default Component(function (props, observables) {
  
  return observables.foo
    .map(function (foo) {
      
      return (
        <div>
          <h1>Hello there {foo}. Message: {props.message}</h1>
        </div>
      );

    });

});

Render

Inject observables to map over in your Components. The function has to return a component that will be mounted on document.body.

import {Render, DOM} from 'r-js';
import observables from './observables.js';
import App from './App.js';

Render(observables, function () {
  return <App message="Wazup?"/>;
});

Hook

Hook allows you to easily push values to a Bus (BaconJS) using push or BehaviorSubject (RxJS) using onNext. You can also bind values to the hook.

import {Component, Hook, DOM} from 'r-js';

exports default Component(function (props, observables) {
  
  return observables.foo
    .map(function (foo) {
      
      return (
        <div>
          <h1>Hello there {foo}. Message: {props.message}</h1>
          <button 
            ev-click={Hook(observables.changeFoo, 'push', 'This is the new value')}
          >Change</button>
        </div>
      );

    });

});

Install

It is highly recommended to use Webpack and babel-loader for JSX and ES6/7 syntax.

  • npm install r-js
  • npm install virtual-dom-loader
  • npm install babel-loader
  • npm install webpack
  • npm install webpack-dev-server

Create a webpack.config.js file in your root folder.

var path = require('path');
var nodeModulesPath = path.resolve(__dirname, 'node_modules');
var appPath = path.resolve(__dirname, 'app');
var buildPath = path.resolve(__dirname, 'build');

var config = {
  entry: path.resolve(appPath, 'main.js'),
  output: {
    path: buildPath,
    filename: 'bundle.js',
  },
  module: {
    loaders: [{
      test: /\.js$/,
      loader: 'babel!virtual-dom?jsx=DOM',
      exclude: [nodeModulesPath]
    }]
  }
};

module.exports = config;

And add a script in your package.json file:

...
"scripts": {
  "start": "webpack-dev-server --devtool eval --progress --colors --content-base build/",
}
...

And last but not least, you need an html file in your build folder. build/index.html.

<body>
  <script src="bundle.js"></script>
</body>

Run your project workflow with npm start.

Please check out react-webpack-cookbook for more info on using webpack.

Run

npm start runs the demo on localhost:8080

Contribute

  • Fork and clone repo
  • npm install
  • npm start starts development flow on localhost:8080
  • npm test run tests