├── .gitignore ├── .watchmanconfig ├── LICENSE ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | 11 | # Directory for instrumented libs generated by jscoverage/JSCover 12 | lib-cov 13 | 14 | # Coverage directory used by tools like istanbul 15 | coverage 16 | 17 | # nyc test coverage 18 | .nyc_output 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # node-waf configuration 24 | .lock-wscript 25 | 26 | # Compiled binary addons (http://nodejs.org/api/addons.html) 27 | build/Release 28 | 29 | # Dependency directories 30 | node_modules 31 | jspm_packages 32 | 33 | # Optional npm cache directory 34 | .npm 35 | 36 | # Optional REPL history 37 | .node_repl_history 38 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": [ 3 | ".git", 4 | "node_modules" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NOT NEEDED ANYMORE 2 | ## This package has been merged into react-native-meteor. https://github.com/inProgress-team/react-native-meteor/pull/135 3 | 4 | # rn-meteor-containerize 5 | A React Container component designed specially for react-native-meteor 6 | 7 | ## Why? 8 | Containerize focus on performance, that's why it hooks up with InteractionManager to ensure that your subscriptions will just be executed when the JS thread isn't dealing with other heavy tasks. 9 | That will ensure smooth transations for Navigator. 10 | 11 | ## Example 12 | The syntax is made to be the same as the one of react-komposer. 13 | 14 | ```js 15 | import composeWithtracker from 'rn-meteor-containerize' 16 | 17 | function composer(props, onData){ 18 | const handle = Meteor.subscribe('items') 19 | 20 | if(handle.ready()){ 21 | onData(null, { 22 | items: Meteor.collections('items').find({}), 23 | }); 24 | } 25 | } 26 | 27 | export default composeWithTracker(composer) 28 | ``` 29 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // Modules 2 | import React, { 3 | Component, 4 | PropTypes, 5 | } from 'react'; 6 | import { 7 | InteractionManager, 8 | } from 'react-native'; 9 | import _ from 'lodash'; 10 | import { connectMeteor } from 'react-native-meteor'; 11 | 12 | export default function(reactiveFn, Loader){ 13 | return Component => { 14 | const displayName = Component.displayName || Component.name || 'Child'; 15 | 16 | const Containerize = class extends Component { 17 | constructor(props){ 18 | super(props); 19 | this.firstRun = true; 20 | } 21 | 22 | _ensurePerformance(reactiveFn){ 23 | // We just need be hold on the execution for now 24 | // during a initial loading and a on-going Navigator scene transition 25 | // to avoid overloading the JS thread with too much work. 26 | if(this.firstRun){ 27 | InteractionManager.runAfterInteractions(() => { 28 | // Calling forceUpdate will do two wanted things: 29 | // 1. Apply any initial data to be rendered; 30 | // 2. Make MeteorDataManager do its cycle calling getMeteorData 31 | // in a computation. 32 | Trackr.afterFlush(() => this.forceUpdate(), 100); 33 | 34 | this.firstRun = false; 35 | }); 36 | } else reactiveFn(); 37 | } 38 | 39 | getMeteorData(){ 40 | let data = {}; 41 | 42 | this._ensurePerformance(reactiveFn.bind(null, this.props, (error, payload) => { 43 | data = payload; 44 | })); 45 | 46 | return data; 47 | } 48 | 49 | render(){ 50 | const props = { 51 | ...this.props, 52 | ...this.data, 53 | }; 54 | 55 | return ; 56 | } 57 | }; 58 | 59 | Containerize.displayName = displayName; 60 | 61 | return connectMeteor(Containerize); 62 | }; 63 | } 64 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rn-meteor-containerize", 3 | "version": "1.0.1", 4 | "description": "A React Container component designed specially for react-native-meteor", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/Astrocoders/rn-meteor-containerize.git" 12 | }, 13 | "keywords": [ 14 | "react-native", 15 | "react-native-component", 16 | "react-native-performance", 17 | "containers" 18 | ], 19 | "author": "Astrocoders ", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/Astrocoders/rn-meteor-containerize/issues" 23 | }, 24 | "homepage": "https://github.com/Astrocoders/rn-meteor-containerize#readme", 25 | "dependencies": { 26 | "lodash": "^4.16.0", 27 | "react-native-meteor": "^1.0.0-rc14" 28 | } 29 | } 30 | --------------------------------------------------------------------------------