Input: Output: . . ├── es ├── effects │ ├── effects.js │ └── package.json │ ├── index.js ├── es │ └── utils.js │ ├── effects.js ├── lib │ ├── index.js │ ├── effects.js │ └── utils.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Available variables: | |
// Machine (machine factory function) | |
// assign (action) | |
// XState (all XState exports) | |
const fetchMachine = Machine({ | |
id: 'fetch', | |
context: { attempts: 0 }, | |
initial: 'idle', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy and paste into https://statecharts.github.io/xstate-viz/ | |
const paginationMachine = Machine( | |
{ | |
id: "pagination", | |
initial: "empty", | |
on: { | |
UPDATE_PARAMS: "debouncing" | |
}, | |
onDone: { actions: "hideMoreLoader" }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | |
}), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// { 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sdk.sendEvent(CHAT_ID, { | |
type: 'annotation', | |
annotation_type: 'rating', | |
properties: { | |
rating: { | |
score: 0, | |
comment: 'You were very helpful', | |
}, | |
}, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger example: | |
{ | |
type: "new_customer", | |
value: true | |
} | |
step: { action, outcomes } | |
action example: |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"optimist": [], | |
"access": { | |
"lastAccepted": null, | |
"isLinkInterstitialEnabled": true, | |
"isVideoInterstitialEnabled": true | |
}, | |
"entities": { | |
"users": { | |
"entities": { |
NewerOlder