Skip to content

Instantly share code, notes, and snippets.

View danielkcz's full-sized avatar
🏗️
Building own experimental dating app

Daniel K. danielkcz

🏗️
Building own experimental dating app
View GitHub Profile
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
@danielkcz
danielkcz / examples.ts
Last active July 15, 2021 02:49
Children handling with React FC
const NoChildrenAllowed: ReactFC<NoChildren> = () => null
const RequireSingleChild: ReactFC<Required<SingleChild>> = () => null
type TProps = Required<SomeChildren> & {
otherProp: number
}
const RequireMoreChildrenAndOtherProps: ReactFC<TProps> = () => null
@danielkcz
danielkcz / machine.js
Created March 14, 2020 17:05
Generated by XState Viz: https://xstate.js.org/viz
const audioStreamMachine = Machine({
id: 'audioStream',
initial: 'idle',
context: {
stream: null,
streamError: null,
},
states: {
idle: {
on: {
@danielkcz
danielkcz / machine.js
Last active January 6, 2020 18:20
Generated by XState Viz: https://xstate.js.org/viz
const tickEvent = (gear) => ({ type: 'TICK', gear })
const trainMachine = Machine(
{
id: 'train',
initial: 'inactive',
context: {
position: {
x: 0,
y: 0,
@danielkcz
danielkcz / machine.js
Last active November 16, 2019 22:32
Generated by XState Viz: https://xstate.js.org/viz
const reset = assign({
value: ({ initialValue }) => initialValue
})
const updateValue = assign({
value: (_, ev) => ev.value
})
const isEnterOrTab = (_, ev) => ['Enter', 'Tab'].includes(ev.key)
@danielkcz
danielkcz / machine.js
Created November 12, 2019 20:10
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@danielkcz
danielkcz / machine.js
Created November 12, 2019 18:41
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@danielkcz
danielkcz / machine.js
Last active November 12, 2019 17:29
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@danielkcz
danielkcz / RandomGiphy.jsx
Last active February 19, 2019 18:42
useQuery reusable
import { observer } from 'mobx-react-lite'
const RandomGiphy = observer(() => {
const settings = useSettings()
const giphy = useRandomGiphy(settings.tag)
return giphy ? <img src={giphy.url} /> : null
})
@danielkcz
danielkcz / SettingsProvider.jsx
Last active February 14, 2019 20:49
useQuery with MobX
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