Skip to content

Instantly share code, notes, and snippets.

View mcousillas6's full-sized avatar

Mauricio Cousillas mcousillas6

View GitHub Profile
import { useEffect, useState } from "react";
export const useDebouncedState = <T>(initialValue: T, delay: number) => {
const [value, setValue] = useState(initialValue);
const [debouncedValue, setDebouncedValue] = useState(initialValue);
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value);
}, delay);
import { useCallback, useReducer, Reducer } from 'react';
enum FormActions {
UPDATE_BLUR = 'UPDATE_BLUR',
UPDATE_ERROR = 'UPDATE_ERROR',
UPDATE_VALUE = 'UPDATE_VALUE',
OVERRIDE_ERRORS = 'OVERRIDE_ERRORS',
OVERRIDE_VALUES = 'OVERRIDE_VALUES',
}
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
enum ColorSpace {
case rainbow
case gray
var colors: [CGColor] {
@mcousillas6
mcousillas6 / gestureExamples.js
Last active August 9, 2023 07:38
react-native-gesture-handler + react-native-reanimate example
import React, { useMemo, useRef } from 'react';
import { View } from 'react-native';
import { node } from 'prop-types';
import { PanGestureHandler, State, PinchGestureHandler } from 'react-native-gesture-handler';
import Animated from 'react-native-reanimated';
import styles from './styles';
/** styles.js
import { StyleSheet } from 'react-native';
@mcousillas6
mcousillas6 / ReactNativeAmplitude.js
Last active August 28, 2019 13:15
Simple wrapper to use Amplitude analytics on react native.
// AnalyticsTracker.js
import Config from 'react-native-config';
import amplitude from 'amplitude-js';
class AnalyticsService {
constructor(apiKey) {
amplitude.getInstance().init(apiKey, null, {
useNativeDeviceInfo: true,
});
}
//
// URLSessionHelpers.swift
//
// Created by Mauricio Cousillas on 6/17/19.
// Copyright © 2019 Mauricio Cousillas. All rights reserved.
//
import Foundation
import Combine
@mcousillas6
mcousillas6 / Navigator.swift
Created June 13, 2019 17:59
SwiftNavigator
//
// Navigator.swift
// SwiftNavigator
//
// Created by Mauricio Cousillas on 02/23/19.
// Copyright © 2019 Mauricio Cousillas. All rights reserved.
//
import Foundation
import UIKit
@mcousillas6
mcousillas6 / LottieButton.swift
Created January 7, 2019 17:37
Custom Lottie Button on iOS
/**
let button = LottieButton(
with: .zero,
and: "success_animation",
onTap: { view in
print("Tapped")
}
)
*/
class LottieButton: LOTAnimationView {

Reactive Programming resources

Introduction

Essentialy this document is a compilation of articles, tutorials and personal experience on learning React programming and specifically, RxSwift and RxCocoa.

One of the best things of Rx is that you can use the same core concepts on any technology that has an implementation of this paradigm. With this in mind, the first section has general knowledge of this paradigm, so it will be useful for any platform (Java, Swift, JavasCript, even C#).

After that, the content will shift more towards iOS and Swift, with advanced content to get the most of RxSwift and RxCocoa.