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 { writable } from 'svelte/store'; | |
/** STATE **/ | |
/// This simply defines the initial state, and serves as a guide for the structure | |
const state = { | |
initialized: false, | |
todos: [] | |
} |
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 { writable } from 'svelte/store'; | |
/** STATE **/ | |
/// This simply defines the initial state, and serves as a guide for the structure | |
const state = { | |
initialized: false, | |
signedIn: false, | |
username: undefined, | |
error: undefined |
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
// | |
// SwiftUI-EnvironmentObjectExample.swift | |
// SwiftUI-DataFlowExamples | |
// | |
// Part of the series beginning at: | |
// https://medium.com/@alexobenauer/demystifying-data-flow-through-swiftui-697017aba7e0 | |
// | |
import SwiftUI | |
import Combine |
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
// | |
// SwiftUI-ObjectBindingExample.swift | |
// SwiftUI-DataFlowExamples | |
// | |
// Part of the series beginning at: | |
// https://medium.com/@alexobenauer/demystifying-data-flow-through-swiftui-697017aba7e0 | |
// | |
import SwiftUI | |
import Combine |
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
// | |
// SwiftUI-BindingExample.swift | |
// SwiftUI-DataFlowExamples | |
// | |
// Part of the series beginning at: | |
// https://medium.com/@alexobenauer/demystifying-data-flow-through-swiftui-697017aba7e0 | |
// | |
import SwiftUI |
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
// | |
// SwiftUI-StateExample.swift | |
// SwiftUI-DataFlowExamples | |
// | |
// Part of the series beginning at: | |
// https://medium.com/@alexobenauer/demystifying-data-flow-through-swiftui-697017aba7e0 | |
// | |
import SwiftUI |
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
// | |
// SwiftUI-PropertyExample.swift | |
// SwiftUI-DataFlowExamples | |
// | |
// Part of the series beginning at: | |
// https://medium.com/@alexobenauer/demystifying-data-flow-through-swiftui-697017aba7e0 | |
// | |
import SwiftUI |
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 Cocoa | |
class ViewController: NSViewController, StoreSubscriber { | |
@IBOutlet weak var counterLabel: NSTextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
store.subscribe(self) |
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
let store = Store(reducer: appReducer, state: nil) | |
struct AppState: State { | |
var counter: Int = 0 | |
} | |
struct IncreaseAction: Action { | |
let increaseBy: Int | |
} |
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 | |
protocol Action { } | |
protocol State { } | |
typealias Reducer = (_ action: Action, _ state: State?) -> State | |
protocol StoreSubscriber { | |
func newState(state: State) |