-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
623 additions
and
523 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,7 @@ | ||
# Editor-specific | ||
.idea | ||
*.sublime-project | ||
*.sublime-workspace | ||
.settings | ||
|
||
# Installed libs | ||
/.vscode | ||
/lib | ||
/coverage | ||
node_modules | ||
|
||
# Generated | ||
test/browser/page/tests-bundle.js | ||
lib/ | ||
|
||
# Secrets | ||
.zuulrc | ||
|
||
# Misc | ||
ignore | ||
npm-debug.log | ||
ts/* | ||
!ts/cycle.d.ts | ||
package-lock.json | ||
shrinkwrap.yaml | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
examples/ | ||
ignore/ | ||
.idea/ | ||
*.sublime-project | ||
*.sublime-workspace | ||
/.vscode | ||
/src | ||
/test | ||
/coverage | ||
.gitignore | ||
node_modules | ||
package-lock.json | ||
shrinkwrap.yaml | ||
yarn.lock | ||
tsconfig.json |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,51 @@ | ||
{ | ||
"name": "@cycle/react-native", | ||
"version": "1.0.0-experimental.15", | ||
"description": "A Cycle.js Driver for interacting with React Native", | ||
"main": "lib/index.js", | ||
"author": "Andre Staltz", | ||
"version": "1.0.0", | ||
"description": "Cycle.js driver that uses React Native to render", | ||
"author": "Andre Staltz <contact@staltz.com>", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/cyclejs/cycle-react-native" | ||
}, | ||
"peerDependencies": { | ||
"rx": ">=3", | ||
"react-native": "~0.24.0" | ||
"bugs": "https://github.com/cyclejs/react-native/issues", | ||
"repository": "https://github.com/cyclejs/react-native/tree/master", | ||
"keywords": [ | ||
"react", | ||
"cyclejs", | ||
"xstream", | ||
"mvi", | ||
"react-native", | ||
"driver" | ||
], | ||
"main": "lib/cjs/index.js", | ||
"typings": "lib/cjs/index.d.ts", | ||
"types": "lib/cjs/index.d.ts", | ||
"dependencies": { | ||
"@cycle/react": "^1.0.2", | ||
"react": "16.4.x", | ||
"react-native": ">=0.55.0", | ||
"xstream": "11.x.x" | ||
}, | ||
"devDependencies": { | ||
"rx": ">=3", | ||
"react-native": "~0.24.0", | ||
"babel": "5.8.x", | ||
"eslint": "1.0.x", | ||
"eslint-config-cycle": "3.0.x", | ||
"eslint-plugin-cycle": "1.0.x", | ||
"eslint-plugin-no-class": "0.1.x", | ||
"markdox": "0.1.9" | ||
"@cycle/run": "^4.4.0", | ||
"@types/mocha": "^2.2.40", | ||
"@types/node": "^10.5.2", | ||
"@types/react": "16.4.x", | ||
"@types/react-native": "0.55.x", | ||
"@types/react-test-renderer": "^16.0.1", | ||
"@huston007/react-native-mock": "^0.3.3", | ||
"mocha": "^5.2.0", | ||
"react-test-renderer": "16.4.1", | ||
"ts-node": "^7.0.0", | ||
"typescript": "2.6.x", | ||
"babel-cli": "^6.24.0", | ||
"babel-preset-react-native": "4.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"eslint": "eslint src/", | ||
"test": "npm run eslint", | ||
"test-ci": "npm run eslint", | ||
"precompile-lib": "rm -rf lib/ && mkdir -p lib", | ||
"compile-lib": "babel -d lib/ src/", | ||
"docs": "node ./scripts/make-api-docs.js", | ||
"prepublish": "npm run compile-lib", | ||
"release": "npm run release-patch", | ||
"release-patch": "git checkout master && npm version patch && git push origin master --tags && npm publish --access=public", | ||
"release-minor": "git checkout master && npm version minor && git push origin master --tags && npm publish --access=public", | ||
"release-major": "git checkout master && npm version major && git push origin master --tags && npm publish --access=public" | ||
"prepublishOnly": "npm run compile", | ||
"compile": "npm run compile-cjs && npm run compile-es6", | ||
"compile-cjs": "tsc --module commonjs --outDir ./lib/cjs", | ||
"compile-es6": "echo 'TODO' : tsc --module es6 --outDir ./lib/es6", | ||
"test": "TS_NODE_PROJECT=test/tsconfig.json mocha test/*.ts --require @huston007/react-native-mock/mock.js --require ts-node/register --recursive" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# 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 | ||
|
||
## Example | ||
|
||
```js | ||
import xs from 'xstream'; | ||
import {run} from '@cycle/run'; | ||
import {makeReactNativeDriver, TouchableOpacity, View, Text} from '@cycle/react-native'; | ||
|
||
function main(sources) { | ||
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(propsObject)` becomes `<View {...props}></View>` | ||
- `Text('text content')` becomes `<Text>text content</Text>` | ||
- `View([child1, child2])` | ||
- `Text(propsObject, 'text content')` | ||
- `View(propsObject, [child1, child2])` | ||
- etc | ||
|
||
There are also shortcuts for (MVI) intent selectors: | ||
|
||
- `Touchable('inc')` becomes `h(Touchable, {selector: 'inc'})` | ||
- `Touchable('inc', propsObject)` becomes `h(Touchable, {selector: 'inc', ...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`. | ||
|
||
## License | ||
|
||
MIT, Andre 'Staltz' Medeiros 2018 | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.