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-native-fluxbone

v0.1.1

Published

A group of libraries that help with the FluxBone pattern in React Native

Downloads

5

Readme

react-native-fluxbone

A group of libraries that help with the FluxBone pattern.

Caution

This is a work in progress and may not be a good idea.

How to use:

var FluxBone = require('react-native-fluxbone');
var React = require('react-native');

var {
  Store,
  Model,
  Dispatcher,
} = FluxBone;

var {
  StyleSheet,
  Text,
  TextInput,
  View,
} = React;

// Create a custom store by extending from Store
var ExampleStore = Store.extend({
  // Avoid a bunch of boilerplate by using a dispatcherEvents hash
  dispatcherEvents: {
    'example:load': 'handleExampleLoad'
  },

  handleExampleLoad: function (text) {
    this.fetch({
      url: 'http://localhost:3000/api/example/' + text
    }).then(function (responseData) {
      // Trigger custom events if necessary on completion
      // NOTE: The standard backbone collection "sync" events also fire
      this.trigger('example:load:complete', responseData);
    }.bind(this), function () {
      // Trigger custom events if necessary on completion
      // NOTE: The standard backbone collection "error" events also fire
      this.trigger('example:load:error');
    }.bind(this));
  }
});

// Instantiate a store
var exampleStore = new ExampleStore();

// Create a screen to interact with
var ExampleScreen = React.createClass({
  displayName: 'ExampleScreen',

  getInitialState: function () {
    return {
      term: '',
      results: null
    }
  },

  componentDidMount: function () {
    // Subscribe to events on the store
    exampleStore.on('example:load:complete', function () {
      console.log('Loaded!');
      this.setState({
        results: exampleStore.getAll()
      });
    }, this);
  },

  componentDidUnmount: function () {
    // Make sure you unsubscribe from the store
    exampleStore.off(null, null, this);
  },

  render: function () {
    return (
      <View style={styles.container}>
        <TextInput
          style={styles.searchBarInput}
          onSubmitEditing={this.onSubmit}
          onChangeText={(text) => this.setState({text: text})}
          />
        {this._renderResults()}
      </View>
    )
  },

  _renderResults: function () {
    if (!this.state.results) {
      return null;
    }

    return this.state.results.map((result) => <Text style={styles.result}>{result.text}</Text>);
  }

  onSubmit: function () {
    Dispatcher.dispatch('example:load', this.state.text);
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'white',
  },
  searchBarInput: {
    fontSize: 15,
    height: 30,
    alignSelf: 'center',
    textAlign: 'center',
    margin: 20,
    width: 100
  },
  result: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 10
  },
});