Skip to content

Instantly share code, notes, and snippets.

View lukebrandonfarrell's full-sized avatar
✌️
fixing bugs since 1996

Luke Brandon Farrell lukebrandonfarrell

✌️
fixing bugs since 1996
View GitHub Profile
@lukebrandonfarrell
lukebrandonfarrell / Alert.js
Last active June 6, 2019 15:53
<Alert /> component styled at project / organisation level.
import React from "react";
import { View, Text } from "react-native";
import palx from "palx" // props to palx!
const ThemeContext = React.createContext(palx("#ff0066"));
const Alert = ({ title, text }) => {
return (
<ThemeContext.Consumer>
{theme => (
<View style={[
@lukebrandonfarrell
lukebrandonfarrell / Alert.js
Created June 6, 2019 15:53
<Alert /> component styled at isolated level.
import React from "react";
import { View, Text } from "react-native";
const Alert = ({ title, text, backgroundColor, borderColor, titleColor, descriptionColor }) => {
return (
<ThemeContext.Consumer>
{theme => (
<View style={[
...,
{
@lukebrandonfarrell
lukebrandonfarrell / Alert.js
Created June 6, 2019 15:53
<Alert /> component styled at specialized level.
import React from "react";
import { View, Text } from "react-native";
const Alert = ({ title, text }) => {
return (
<ThemeContext.Consumer>
{theme => (
<View style={[
...,
{
@lukebrandonfarrell
lukebrandonfarrell / async-function
Created June 13, 2019 06:34
Running an async function directly in block 🕒
...
(async () => {
await // Do something async
})();
...
@lukebrandonfarrell
lukebrandonfarrell / network-layer-example.js
Last active June 18, 2019 07:39
A saga example from the redux saga network layer pattern.
import { all, call, put, takeLatest } from "redux-saga/effects";
import { FETCH_USER_ORDERS_REQUEST, FETCH_USER_ORDERS_RESPONSE } from "../types";
import { fetchOrdersRequest } from "../api";
export function* fetchUserOrders(action, baseUrl) {
try {
const { filter } = action.payload;
const orders = yield call(fetchOrdersRequest, baseUrl, filter);
yield put({
@lukebrandonfarrell
lukebrandonfarrell / abstract-network-layer-saga.js
Last active June 17, 2019 18:48
A abstract saga for composing request for the redux-saga network layer pattern.
import { put, call } from "redux-saga";
export function* AbstractAPISaga(
action,
baseUrl,
api,
type,
) {
try {
const payload = { ...action.payload };
@lukebrandonfarrell
lukebrandonfarrell / network-layer-abstract-example.js
Last active June 17, 2019 18:47
An abstract saga example from the redux saga network layer pattern.
import { all, call, takeLatest } from "redux-saga/effects";
import { FETCH_USER_ORDERS_REQUEST, FETCH_USER_ORDERS_RESPONSE } from "../types";
import { fetchOrdersRequest } from "../api";
import { AbstractAPISaga } from "../AbstractAPISaga";
export default function* UserOrdersSaga (baseUrl) {
yield all([
yield takeLatest(FETCH_USER_ORDERS_REQUEST,
action => AbstractAPISaga(action, baseUrl, fetchOrdersRequest, FETCH_USER_ORDERS_RESPONSE)
]);
RCT_EXPORT_METHOD(
confirmPaymentIntent:(NSString *)payment_intent_client_secret
resolvePromise:(RCTPromiseResolveBlock)resolve
rejectPromise:(RCTPromiseRejectBlock)reject
)
{
// Create the payment intent using the payment_intent_client_secret
[[STPAPIClient sharedClient] retrievePaymentIntentWithClientSecret:payment_intent_client_secret completion:^(STPPaymentIntent *paymentIntent, NSError *error) {
NSLog(@"Intent %@", paymentIntent);
@lukebrandonfarrell
lukebrandonfarrell / funnels.ts
Created August 13, 2019 08:14
Funnels TypeScript implementation for RMN
/**
* @author Luke Brandon Farrell
* @description Funnels allow us to re-use screens with react-native-navigation
* and build more complex patterns. In the context of this utility a stack
* refers to a single screen, where as a funnel refres to a collection of screens.
*/
import { Platform } from "react-native";
import { Navigation, Layout, Options } from "react-native-navigation";
import * as NavigationLayouts from "react-native-navigation-layouts";
@lukebrandonfarrell
lukebrandonfarrell / ActionReducer.js
Last active March 4, 2023 12:57
A hook to listen to Redux actions in your component.
const initialState = {
type: null,
payload: null,
meta: null,
error: false
};
export default (state = initialState, action) => {
return {
...state,