This file contains hidden or 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
struct AppState { | |
var user: User | |
var newsState: NewsState? | |
} | |
enum AppEvent { | |
case newUserWasLoaded(User) | |
case newsEvents(NewsEvent) | |
} |
This file contains hidden or 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
struct AppState { | |
var user: User | |
} | |
enum AppEvent { | |
case newUserWasLoaded(User) | |
} | |
extension AppEvent { | |
static func reduce(state: AppState, event: AppEvent) -> AppState { | |
var state = state | |
switch event { |
This file contains hidden or 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
struct User { | |
let id: AnyHashable | |
} | |
struct NewsState { | |
var user: User | |
var step: Step | |
} | |
extension NewsState { | |
enum Step { | |
case initial |
This file contains hidden or 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 Combine | |
import Foundation | |
func loadNewsTitles() -> AnyPublisher<[String], Never> { | |
["title1", "title2"] | |
.publisher | |
.delay(for: .microseconds(500), scheduler: DispatchQueue.main) | |
.collect() | |
.eraseToAnyPublisher() | |
} |
This file contains hidden or 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
Twitter(.atimca) | |
.subscribe(onNext: { newArcticle in | |
you.read(newArticle) | |
}) |
This file contains hidden or 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
protocol Observer { | |
func stateWasChanged(with newState: State) | |
} | |
struct State { | |
var value: Int? | |
static func reduce(state: State, event: Event) -> State { | |
var state = state | |
switch event { |
This file contains hidden or 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
class Store { | |
func accept(event: Event) { | |
state = reduce(state: state, event: event) | |
} | |
func reduce(state: State, event: Event) -> State { | |
var state = state | |
switch event { | |
case .changeValue(let newValue): | |
state.value = newValue |
This file contains hidden or 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
func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, Element) -> Result) -> Result |
This file contains hidden or 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
Question set for interviews | |
Developer | |
Tech | |
- [ ] How many projects do you have | |
- [ ] Which architectures approaches do you use | |
- [ ] Which swift version / legacy objc, c what are you going to do with it. | |
- [ ] Do you do layout in xibs or in code? | |
- [ ] What do you think about reactive programming (RxSwift) |
This file contains hidden or 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 PlaygroundSupport | |
import Foundation | |
class WeakRef<T> where T: AnyObject { | |
private(set) weak var value: T? | |
init(value: T?) { | |
self.value = value | |
} |