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) -> Store
Parameters
reducer
the reducer (or reducers) to use with the store. The reducer will be called when calling dispatch on this store
state
the initial state to use for this store
middleware
the 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) -> Store
Parameters
reducer
the reducer (or reducers) to use with the store. The reducer will be called when calling dispatch on this store.
state
the initial state to use for this store. The state type must be equal to the reducer
StateType
middleware
the store middleware or middlewares.
Return Value
a new store
-
Create a store.
The state will be generated from calling
reducer.initialState
Example
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) -> Store
Parameters
reducer
the reducer (or reducers) to use with the store. The reducer will be called when calling dispatch on this store.
middleware
the store middleware or middlewares.
Return Value
a new store.