Skip to content

Instantly share code, notes, and snippets.

@eightyfive
Last active January 24, 2022 10:49
Show Gist options
  • Save eightyfive/c1e159a3566165fadc7032b746ea7e16 to your computer and use it in GitHub Desktop.
Save eightyfive/c1e159a3566165fadc7032b746ea7e16 to your computer and use it in GitHub Desktop.
rnna app structure
$ npx yown @rnna/app

$ npm install rnna react-native-flipper @react-native-async-storage/async-storage

$ npm install --save-dev redux-flipper rn-async-storage-flipper


# Optional
$ npx yown @rnna/app-starter
import { Platform } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
const isAndroid = Platform.OS === 'android';
const middlewares = [];
const config = {
middlewares,
persist: {
key: 'root',
storage: AsyncStorage,
whitelist: ['session'],
},
};
if (__DEV__) {
// AsyncStorage.clear();
// Redux Flipper
const createDebugger = require('redux-flipper').default;
middlewares.push(createDebugger());
// AsyncStorage Flipper
const asyncStorageFlipper = require('rn-async-storage-flipper').default;
asyncStorageFlipper(AsyncStorage);
if (isAndroid) {
// https://github.com/facebook/react-native/issues/14101
// https://github.com/rt2zz/redux-persist/issues/717#issuecomment-437589374
config.persist.timeout = 0;
}
}
export default config;
export default Object.assign(
{
API_URL: 'https://example.org/api',
},
__DEV__ && {
API_URL: 'http://127.0.0.1:8000/api',
},
);
import { onBoot } from 'rnna/events';
export default onBoot(main);
function main(services) {
//
}
import boot from "./boot";
import register from "./register";
import runtime from "./runtime";
const events = [register, boot, ...runtime];
export default events;
import { onRegister } from "rnna/events";
export default onRegister(main);
function main(services) {
//
}
import { onAction as on } from "rnna/events";
const events = [
on("app/dummy", (services, payload, meta) => {})
];
export default events;
import createStoreAsync from "rnna/store";
import epics from "./events";
import reducers from "./state";
import container from "./services";
import storeConfig from "./config/store";
const storeAsync = createStoreAsync(
{ ...storeConfig, epics, reducers },
container
);
const app = {
boot() {
return storeAsync;
},
};
export default app;
const routes = {
//
};
export default routes;
import { Container } from "rnna";
const container = new Container();
//
export default container;
const reducers = {
//
};
export default reducers;
const screens = {
//
};
export default screens;
{
"dir": "app",
"keywords": ["rnna", "react-native", "react-native-navigation"],
"dependencies": [
"rnna",
"@react-native-community/async-storage",
"react-native-flipper"
],
"devDependencies": [
"redux-flipper",
"rn-async-storage-flipper"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment