Skip to content

Instantly share code, notes, and snippets.

🏗️
Building own experimental dating app

Daniel K. FredyC

🏗️
Building own experimental dating app
View GitHub Profile
View HasuraEventTriggerPayload.ts
export type TEventTriggerPayload<TData> = {
event: (
| TEvent<'INSERT', null, TData>
| TEvent<'UPDATE', TData, TData>
| TEvent<'DELETE', TData, null>
| TEvent<'MANUAL', null, TData>
) & {
session_variables: Dictionary
}
created_at: ISODateTime
@FredyC
FredyC / examples.ts
Last active Jun 10, 2020
Children handling with React FC
View examples.ts
const NoChildrenAllowed: ReactFC<NoChildren> = () => null
const RequireSingleChild: ReactFC<Required<SingleChild>> = () => null
type TProps = Required<SomeChildren> & {
otherProp: number
}
const RequireMoreChildrenAndOtherProps: ReactFC<TProps> = () => null
View machine.js
const audioStreamMachine = Machine({
id: 'audioStream',
initial: 'idle',
context: {
stream: null,
streamError: null,
},
states: {
idle: {
on: {
View machine.js
const tickEvent = (gear) => ({ type: 'TICK', gear })
const trainMachine = Machine(
{
id: 'train',
initial: 'inactive',
context: {
position: {
x: 0,
y: 0,
View machine.js
const reset = assign({
value: ({ initialValue }) => initialValue
})
const updateValue = assign({
value: (_, ev) => ev.value
})
const isEnterOrTab = (_, ev) => ['Enter', 'Tab'].includes(ev.key)
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@FredyC
FredyC / RandomGiphy.jsx
Last active Feb 19, 2019
useQuery reusable
View RandomGiphy.jsx
import { observer } from 'mobx-react-lite'
const RandomGiphy = observer(() => {
const settings = useSettings()
const giphy = useRandomGiphy(settings.tag)
return giphy ? <img src={giphy.url} /> : null
})
@FredyC
FredyC / SettingsProvider.jsx
Last active Feb 14, 2019
useQuery with MobX
View SettingsProvider.jsx
import React from 'react'
const context = React.createContext(mobx.observable({
tag: 'kittens'
}))
export const SettingsProvider = ({ children }) => {
// we can employ some persistence here and load previous settings
// for now just return children because context already has state set
return children
You can’t perform that action at this time.