Skip to content

Instantly share code, notes, and snippets.

View FreddyPoly's full-sized avatar
🍎

Frédéric Llorca FreddyPoly

🍎
  • 05:49 (UTC +02:00)
View GitHub Profile
@FreddyPoly
FreddyPoly / component.tsx
Created June 28, 2019 16:41
[REACT NATIVE] Ramda Usage Example
import { contains } from "ramda"
export class ComponentTest extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {}
}
_function = () => {
@FreddyPoly
FreddyPoly / component.ts
Created June 28, 2019 16:38
[REACT NATIVE] Mobx Component Usage Example
import * as React from "react"
import { View } from "react-native"
import { ApiStore } from "../../services/api/api-store"
import { inject } from "mobx-react"
export interface FirstExampleScreenProps extends NavigationScreenProps<{}> {
apiStore: ApiStore,
}
@inject("apiStore")
@FreddyPoly
FreddyPoly / app.tsx
Created June 28, 2019 16:33
[REACT NATIVE] Mobx app.tsx Example
...
return (
<Provider rootStore={rootStore} navigationStore={rootStore.navigationStore} apiStore={rootStore.apiStore} {...otherStores}>
<BackButtonHandler canExit={this.canExit}>
<StatefulNavigator />
</BackButtonHandler>
</Provider>
)
}
@FreddyPoly
FreddyPoly / root-store.ts
Created June 28, 2019 16:31
[REACT NATIVE] Mobx root-store Example
import { Instance, SnapshotOut, types } from "mobx-state-tree"
import { NavigationStoreModel } from "../../navigation/navigation-store"
import { ApiStoreModel } from "../../services/api/api-store"
/**
* An RootStore model.
*/
export const RootStoreModel = types.model("RootStore").props({
navigationStore: types.optional(NavigationStoreModel, {}),
apiStore: types.optional(ApiStoreModel, {}),
@FreddyPoly
FreddyPoly / api-store.ts
Created June 28, 2019 16:30
[REACT NATIVE] Mobx Model Example
import { Instance, types, getEnv } from "mobx-state-tree"
export const ApiStoreModel = types
.model()
.props({
})
.actions(self => ({
test(){
return getEnv(self).api.getUser('1');
},
@FreddyPoly
FreddyPoly / file.ts
Created June 28, 2019 16:26
[REACT NATIVE] API Service Usage Example
import API_SERVICE from './api';
export default {
async get() {
return await API_SERVICE.get()
.then((res) => {
// L'appel API est arrivé au bout
return res;
})
.catch((err) => {
@FreddyPoly
FreddyPoly / api-service.ts
Created June 28, 2019 16:19
[REACT NATIVE] API Service Example
import * as env from "../../environment-variables"
export default {
get() {
let didTimeout = false;
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
didTimeout = true;
reject(new Error('Request timed out'));
@FreddyPoly
FreddyPoly / component.tsx
Created June 28, 2019 16:11
[REACT NATIVE] Usage Async Storage Example
import * as ls from "../../utils/storage"
export class ComponentTest extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {}
}
_saveString = () => {
@FreddyPoly
FreddyPoly / component.tsx
Created June 28, 2019 16:05
[REACT NATIVE] Example component TypeScript
import * as React from "react"
import { View, Text } from "react-native"
export interface Props {
propsVar: any;
}
export interface State {
stateVar: any;
}
@FreddyPoly
FreddyPoly / terminal.txt
Last active May 22, 2019 13:41
[MOBILE] Record Android Screen
- Se placer dans le dossier où l'on voudra avoir la vidéo
- Lancer la capture:
`adb shell screenrecord /sdcard/nom_de_la_video.mp4`
- Stopper la capture:
`CTRL + C`