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
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() |
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
const lightMachine = Machine({ | |
key: 'light', | |
initial: 'green', | |
states: { | |
green: { | |
on: { NEXT: "yellow" } | |
}, | |
yellow: { on: { NEXT: "red" }}, | |
red: { | |
initial: 'green', |
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 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 |
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
const lightMachine = Machine({ | |
// not a parallel machine | |
id: 'parallel', | |
// initial: 'green', | |
// states: { | |
// green: { | |
// on: { TIMER: 'yellow' } | |
// }, | |
// yellow: { |
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
const wizardMachine = Machine({ | |
id: 'wizard', | |
initial: 'open', | |
states: { | |
open: { | |
initial: 'step1', | |
states: { | |
step1: { | |
on: { NEXT: 'step2' } | |
}, |
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
const addToUpload = assign({ | |
uploadAmount: (context, event) => context.uploadAmount + 2 | |
}); | |
const addToDownload = assign({ | |
downloadAmount: (context, event) => context.downloadAmount + 2 | |
}); | |
const fileMachine = Machine({ | |
id: '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
const fetchMachine = Machine({ | |
id: 'fetch', | |
// Initial state | |
initial: 'idle', | |
// States | |
states: { | |
idle: { | |
on: { |
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
const fetchMachine = Machine({ | |
id: 'fetch', | |
// Initial state | |
initial: 'idle', | |
// States | |
states: { | |
idle: { | |
on: { |
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
const factoryViewing = Machine({ | |
id: 'factoryViewing', | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
LOAD: 'loading' | |
} | |
}, | |
loading: { |
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
const promiseMachine = Machine({ | |
id: 'promise', | |
initial: 'pending', | |
states: { | |
pending: { | |
on: { | |
// state transition (shorthand) | |
// this is equivalent to { target: 'resolved' } | |
RESOLVE: 'resolved', |
NewerOlder