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

@cycle/react-native

v3.0.0

Published

Cycle.js driver that uses React Native to render

Downloads

43

Readme

Cycle React Native

Cycle.js driver that uses React Native to render

  • Provides a driver factory makeReactNativeDriver
  • Contains hyperscript helper functions, such as View(), Text(), etc
npm install @cycle/react-native

Example

import xs from 'xstream';
import {run} from '@cycle/run';
import {makeReactNativeDriver, TouchableOpacity, View, Text} from '@cycle/react-native';

function main(sources) {
  const inc = Symbol();
  const inc$ = sources.react.select(inc).events('click');

  const count$ = inc$.fold(count => count + 1, 0);

  const elem$ = count$.map(i =>
    TouchableOpacity(inc, [
      View([
        Text(`Counter: ${i}`),
      ])
    ]),
  );

  return {
    react: elem$,
  };
}

run(main, {
  react: makeReactNativeDriver('MyApp'),
});

Installation

Start by installing React Native prerequisites (XCode, react-native-cli, watchman).

Then create a React Native project using the CLI.

When the project is set up, npm install @cycle/react-native, @cycle/run, and a stream library like xstream, then replace the index.js with something that looks like the example code in this readme.

API

makeReactNativeDriver(appKey)

Returns a driver that uses React Native to render your Cycle.js app in the native application known by the string appKey.

Hyperscript helpers

Import hyperscript helpers such as View, Text, TouchableOpacity, etc to create React elements to represent the respective built-in native components: <View>, <Text>, <TouchableOpacity>, etc.

The basic usage is View(props, children), but some variations and shortcuts are allowed:

  • View() becomes <View/>
  • View(props) becomes <View {...props}></View>
  • Text('text content') becomes <Text>text content</Text>
  • View([child1, child2])
  • Text(props, 'text content')
  • View(props, [child1, child2])
  • etc

There are also shortcuts for (MVI) intent selectors:

  • Touchable(someSymbol) becomes h(Touchable, {sel: someSymbol})
  • Touchable(sym, props) becomes h(Touchable, {sel: sym, ...props})
  • Text('myselector', 'text content')
  • Touchable('inc', [child])
  • Touchable('inc', propsObject, [child])
  • etc

For non-built-in components (e.g. third party) components, you can use h(ThirdPartyComponent) with h from @cycle/react or you can build a helper using makeHelper(ThirdPartyComponent) with makeHelper from @cycle/react-native.

Other native drivers

This library only covers React components in React Native and View-related rendering. For other native APIs in React Native, use drivers specifically built for those. See the list below:

License

MIT, Andre 'Staltz' Medeiros 2018