Skip to content

Instantly share code, notes, and snippets.

@joeporpeglia
joeporpeglia / livekit-config-plugin.ts
Created September 14, 2023 21:05
Expo config plugin for LiveKit
function withLivekit(config: ExpoConfig): ExpoConfig {
config = withLivekitAndroid(config);
config = withLivekitIOS(config);
return config;
}
function withLivekitAndroid(expoConfig: ExpoConfig): ExpoConfig {
return withMainApplication(expoConfig, (config) => {
let contents = config.modResults.contents;
// Replace com.example with your package name
@joeporpeglia
joeporpeglia / mvc.jsx
Last active March 16, 2018 03:39
React MVC architecture thoughts
import React from 'react';
import createModelComponent from './create-model-component';
import { Post } from 'restful';
const Model = createModelComponent(0, {
increment: () => prevState => prevState + 1,
decrement: () => prevState => prevState - 1,
});
@joeporpeglia
joeporpeglia / app.jsx
Last active February 26, 2019 18:45
React Redux with the new React Context API. I didn't test this at all...
import React from 'react';
import Counter from './counter';
const mapProps = ({ state, dispatch }) => ({
count: state,
increment: () => dispatch({
type: 'increment',
}),
decrement: () => dispatch({
@joeporpeglia
joeporpeglia / Counter.jsx
Created September 22, 2017 15:31
Redux as a Render Prop
import StoreProvider from './StoreProvider';
const increment = { type: '@counter/increment' };
const decrement = { type: '@counter/decrement' };
const initialState = { count: 0 };
const reducer = (state = initialState, action) => {
switch (action.type) {
case increment.type:
@joeporpeglia
joeporpeglia / Dropdown.jsx
Last active June 30, 2017 16:25
Component Reusability
type DropdownProps = {
expanded: boolean,
value: string | number,
onChange: (string | number) => void,
onExpand: () => void,
onCollapse: () => void,
options: {
[optionValue: string | number]: string | React$Element
},
};