Skip to content

Instantly share code, notes, and snippets.

View pavankataria's full-sized avatar

Pavan Kataria pavankataria

View GitHub Profile
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
/// 1. Capture the scene
guard let windowScene = (scene as? UIWindowScene) else { return }
/// 2. Create a new UIWindow using the windowScene constructor which takes in a window scene.
let window = UIWindow(windowScene: windowScene)
/// 3. Create a view hierarchy programmatically
let viewController = ArticleListViewController()
@pavankataria
pavankataria / machine.js
Last active January 2, 2021 03:47
Generated by XState Viz: https://xstate.js.org/viz
// A very cool visualisation machine
// Allows you to see what the state machine does
// And how it transitions from one state to the next
const toggleMachine = new Machine({
id: 'toggleMachine',
initial: 'inactive',
states: {
inactive: {
// Tell it which events the state should listen for.
// And you do that by defining an on property.
@pavankataria
pavankataria / machine.js
Last active January 2, 2021 12:57
Generated by XState Viz: https://xstate.js.org/viz
const allData = new Array(25).fill(0).map((_valu, i) => i + 1);
const perPage = 10;
const dataMachine = new Machine({
id: 'dataMachine',
initial: 'loading',
context: {
data: []
},
states: {
@pavankataria
pavankataria / machine.js
Last active December 28, 2021 19:01
Generated by XState Viz: https://xstate.js.org/viz
const lightMachine = Machine({
key: 'light',
initial: 'green',
states: {
green: {
on: { NEXT: "yellow" }
},
yellow: { on: { NEXT: "red" }},
red: {
initial: 'green',
@pavankataria
pavankataria / machine.js
Last active January 3, 2021 04:41
Generated by XState Viz: https://xstate.js.org/viz
const promiseMachine = Machine({
id: 'promise',
initial: 'pending',
states: {
pending: {
on: {
// state transition (shorthand)
// this is equivalent to { target: 'resolved' }
RESOLVE: 'resolved',
@pavankataria
pavankataria / machine.js
Created January 2, 2021 20:49
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'fetch',
// Initial state
initial: 'idle',
// States
states: {
idle: {
on: {
@pavankataria
pavankataria / machine.js
Created January 2, 2021 21:03
Generated by XState Viz: https://xstate.js.org/viz
const pedestrianStates = {
initial: 'walk',
states: {
walk: {
on: {
PED_COUNTDOWN: 'wait'
}
},
wait: {
on: {
@pavankataria
pavankataria / machine.js
Created January 3, 2021 00:06
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'fetch',
// Initial state
initial: 'idle',
// States
states: {
idle: {
on: {
@pavankataria
pavankataria / machine.js
Created January 3, 2021 01:01
Generated by XState Viz: https://xstate.js.org/viz
const lightMachine = Machine({
id: 'light',
initial: 'green',
states: {
green: {
on: { TIMER: 'yellow' }
},
yellow: {
on: { TIMER: 'red' }
},
@pavankataria
pavankataria / machine.js
Last active January 3, 2021 06:12
Generated by XState Viz: https://xstate.js.org/viz
const factoryViewing = Machine({
id: 'factoryViewing',
initial: 'idle',
states: {
idle: {
on: {
LOAD: 'loading'
}
},
loading: {