9. FLUX
Flux is the application architecture that Facebook uses for
building client-side web applications. It complements React's
composable view components by utilizing a unidirectional
data flow. It's more of a pattern rather than a formal
framework, and you can start using Flux immediately without a
lot of new code.
12. FRUSTRACJA
▸ Frustracja (łac. frustratio - zawód, udaremnienie) – zespół
przykrych emocji związanych z niemożliwością realizacji
potrzeby lub osiągnięcia określonego celu.
▸ np. Gdy kolejny raz odtwarzasz stan aplikacji podczas pracy
nad nową funkcjonalnością
46. STAN APLIKACJI SKŁADA SIĘ Z PODSTANÓW
struct ApplicationState {
var companyState: CompanyState
var loginState: LoginState
var user: User
var navigationState: NavigationState
}
75. ACTION CREATOR
struct CounterSetValue: Action {
var value: Int
}
func setCounterValue() {
countRepository.getCount { count in
store.dispatch(CounterSetValue(value: count))
}
}
76. REDUCER
func counterReducer(action: Action, state: AppState?) -> AppState {
var state = state ?? AppState()
switch action {
case _ as CounterIncrease:
state.counter += 1
case _ as CounterDecrease:
state.counter -= 1
case let valueAction as CounterSetValue:
state.counter = valueAction.value
default:
break
}
return state
}
77. REAKCJA NA ZMIANE
class CounterViewController: UIViewController, StoreSubscriber {
func newState(state: AppState) {
counterLabel.text = "Counter: (state.counter)"
}
}
89. PRZECHOWYWANIE STANU
class ComponentA {
var state: State?
var componentB: ComponentB
func applyState(state: State) {
self.state = state
componentB.applyState(state)
}
}
class ComponentB {
var state: State?
func applyState(state: State) {
self.state = state
}
}
90. USTAWIANIE STANU
class ComponentA {
var componentB: ComponentB
func applyState(state: State) {
componentB.applyState(state)
}
}
class ComponentB {
func applyState(state: State) {
}
}