StoreValue

@propertyWrapper
public struct StoreValue<State, Value> where Value : Equatable

A property wrapper for observing a value in the Store.

import Fluxor
import SwiftUI

struct DrawView: View {
    @StoreValue(Current.store, Selectors.canClear) private var canClear: Bool

    var body: some View {
        Button(action: { ... }, label: { Text("Clear") })
            .disabled(!canClear)
    }
}
  • The current value in the Store

    Declaration

    Swift

    public var wrappedValue: Value { get }
  • A Publisher for the selecterd value in the Store

    Declaration

    Swift

    public var projectedValue: AnyPublisher<Value, Never>
  • Initializes the StoreValue property wrapper with a Store and a Selector.

    Declaration

    Swift

    public init<Environment>(_ store: Store<State, Environment>, _ selector: Selector<State, Value>)

    Parameters

    store

    The Store to select the value from

    selector

    The Selector to use for selecting the value