Skip to content

Instantly share code, notes, and snippets.

View Andarist's full-sized avatar

Mateusz Burzyński Andarist

View GitHub Profile
@Andarist
Andarist / machine.js
Created July 15, 2019 22:30
Generated by [XState Viz](https://xstate.js.org/viz)
// Available variables:
// Machine (machine factory function)
// assign (action)
// XState (all XState exports)
const fetchMachine = Machine({
id: 'fetch',
context: { attempts: 0 },
initial: 'idle',
// Copy and paste into https://statecharts.github.io/xstate-viz/
const paginationMachine = Machine(
{
id: "pagination",
initial: "empty",
on: {
UPDATE_PARAMS: "debouncing"
},
onDone: { actions: "hideMoreLoader" },
@Andarist
Andarist / cherry-pick_tree_example.md
Last active June 7, 2018 08:39
cherry-pick tree example
Input:                 Output:

.                      .
├── es                 ├── effects
│   ├── effects.js     │   └── package.json
│   ├── index.js       ├── es
│   └── utils.js       │   ├── effects.js
├── lib                │   ├── index.js
│   ├── effects.js │   └── utils.js
import nodeResolve from 'rollup-plugin-node-resolve'
import babel from 'rollup-plugin-babel'
import pkg from './package.json'
const mergeAll = objs => Object.assign({}, ...objs)
const commonPlugins = [
babel({
plugins: ['external-helpers'],
}),
@Andarist
Andarist / gist:83d1c29d9fd565d91d2c3feffbf8b3b1
Last active January 23, 2018 17:41
types relations problem
// { type: 'A', payload: { timestamp: number } }
// { type: 'B', payload: { user_id: string } }
const parseA = data => ({ lastTimestamp: data * 1000 })
const parseB = data => ({ userId: data })
const serverMessageParser = (msg: SocketMessage): ParsedMessage => {
switch (msg.action) {
case 'A':
return parseA(msg.data)
sdk.sendEvent(CHAT_ID, {
type: 'annotation',
annotation_type: 'rating',
properties: {
rating: {
score: 0,
comment: 'You were very helpful',
},
},
})
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { AuthWebView } from '@livechat/chat.io-customer-auth';
import { init } from '@livechat/chat.io-customer-sdk'
export default class App extends React.Component {
componentDidMount() {
const sdk = init({ license: 100004225 })
sdk.on('connected', ({ chatsSummary, totalChats }) => {
console.log('on connected', { chatsSummary, totalChats })
trigger example:
{
type: "new_customer",
value: true
}
step: { action, outcomes }
action example:
This file has been truncated, but you can view the full file.
{
"optimist": [],
"access": {
"lastAccepted": null,
"isLinkInterstitialEnabled": true,
"isVideoInterstitialEnabled": true
},
"entities": {
"users": {