Suas
Undocumented
-
Create a store
Example
Using a single reducer
let store = Suas.createStore( reducer: MyReducer() )Using a single reducer and some initial state
let store = Suas.createStore( reducer: MyReducer(), state: ["MyReducerState": MyReducerState(val: 20)] )let store = Suas.createStore( reducer: MyReducer(), state: MyReducerState(val: 20) )Using a combination of reducers
let store = Suas.createStore( reducer: MyReducer() + MyOtherReducer() )Using a single middleware
let store = Suas.createStore( reducer: ..., middleware: LoggerMiddleware() )Using multiple middlewares
let store = Suas.createStore( reducer: ..., middleware: MyMiddleware() + LoggerMiddleware() )Declaration
Swift
public static func createStore<R: Reducer>(reducer: R, state: KeyedState, middleware: Middleware? = nil) -> StoreParameters
reducerthe reducer (or reducers) to use with the store. The reducer will be called when calling dispatch on this store
statethe initial state to use for this store
middlewarethe store middleware or middlewares.
Return Value
a new store
-
Create a store
Example
Using a single reducer
let store = Suas.createStore( reducer: MyReducer() )Using a single reducer and some initial state
let store = Suas.createStore( reducer: MyReducer(), state: ["MyReducerState": MyReducerState(val: 20)] )let store = Suas.createStore( reducer: MyReducer(), state: MyReducerState(val: 20) )Using a combination of reducers
let store = Suas.createStore( reducer: MyReducer() + MyOtherReducer() )Using a single middleware
let store = Suas.createStore( reducer: ..., middleware: LoggerMiddleware() )Using multiple middlewares
let store = Suas.createStore( reducer: ..., middleware: MyMiddleware() + LoggerMiddleware() )Declaration
Swift
public static func createStore<R: Reducer, StateType>(reducer: R, state: StateType, middleware: Middleware? = nil) -> StoreParameters
reducerthe reducer (or reducers) to use with the store. The reducer will be called when calling dispatch on this store.
statethe initial state to use for this store. The state type must be equal to the reducer
StateTypemiddlewarethe store middleware or middlewares.
Return Value
a new store
-
Create a store.
The state will be generated from calling
reducer.initialStateExample
Using a single reducer
let store = Suas.createStore( reducer: MyReducer() )Using a combination of reducers
let store = Suas.createStore( reducer: MyReducer() + MyOtherReducer() )Using a single middleware
let store = Suas.createStore( reducer: ..., middleware: LoggerMiddleware() )Using multiple middlewares
let store = Suas.createStore( reducer: ..., middleware: MyMiddleware() + LoggerMiddleware() )Declaration
Swift
public static func createStore<R: Reducer>(reducer: R, middleware: Middleware? = nil) -> StoreParameters
reducerthe reducer (or reducers) to use with the store. The reducer will be called when calling dispatch on this store.
middlewarethe store middleware or middlewares.
Return Value
a new store.
View on GitHub
Suas Enum Reference