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 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 / GenericTableViewCell.plagrounds
Created October 6, 2017 13:54
Injecting View into Generic TableViewCell
import Foundation
import UIKit
public protocol CellRepresentable {
static func registerCell(tableView: UITableView)
func dequeueCell(tableView: UITableView, indexPath: IndexPath) -> UITableViewCell
func cellSelected(_ indexPath: IndexPath)
}
//MARK: - Default Implementation
@pavankataria
pavankataria / machine.js
Last active February 5, 2021 06:27
Generated by XState Viz: https://xstate.js.org/viz
const lightMachine = Machine({
// not a parallel machine
id: 'parallel',
// initial: 'green',
// states: {
// green: {
// on: { TIMER: 'yellow' }
// },
// yellow: {
@pavankataria
pavankataria / machine.js
Created January 29, 2021 06:48
Generated by XState Viz: https://xstate.js.org/viz
const wizardMachine = Machine({
id: 'wizard',
initial: 'open',
states: {
open: {
initial: 'step1',
states: {
step1: {
on: { NEXT: 'step2' }
},
@pavankataria
pavankataria / machine.js
Created January 15, 2021 04:01
Generated by XState Viz: https://xstate.js.org/viz
const addToUpload = assign({
uploadAmount: (context, event) => context.uploadAmount + 2
});
const addToDownload = assign({
downloadAmount: (context, event) => context.downloadAmount + 2
});
const fileMachine = Machine({
id: 'file',
@pavankataria
pavankataria / machine.js
Created January 5, 2021 00:42
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 4, 2021 00:26
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
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: {
@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',