Skip to content

Instantly share code, notes, and snippets.

AlexanderBollbach AlexanderBollbach

Block or report user

Report or block AlexanderBollbach

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:c6e85172ace5f16132cd51b4301cf45a
import SwiftUI
final class Store<Value, Action>: ObservableObject {
let reducer: (inout Value, Action) -> Void
@Published private(set) var value: Value
init(initialValue: Value, reducer: @escaping (inout Value, Action) -> Void) {
self.reducer = reducer
self.value = initialValue
View gist:10452e09edb3add9369b9dad07fd18a2
import SwiftUI
final class Store<Value, Action>: ObservableObject {
let reducer: (inout Value, Action) -> Void
@Published private(set) var value: Value
init(initialValue: Value, reducer: @escaping (inout Value, Action) -> Void) {
self.reducer = reducer
self.value = initialValue
View gist:6f66a250c4ec2642cb4b94cd865fc850
struct Test: View {
let binding: Binding<String>
let store: Store<AppState, AppAction>
init(store: Store<AppState, AppAction>) {
self.store = store
self.binding = .init(
get: { store.value.testVal },
set: { store.send(.setTestVal($0)) }
View gist:edbe81cfe0ea494585802b363bde9b07
init<ItemType: ListItemDisplayable>(
menuItems: Observable<[ContextMenuItem]> = .just([]),
getTitle: @escaping () -> Single<String> = { .just("") },
getItems: @escaping ItemsFetcher<ItemType>,
externalReload: Observable<Void> = env.reload.asObservable(),
filteringEnabled: Bool = false,
emptyListMessage: String = "There are no items to show",
filterFunc: @escaping ListItemFilterFunction<ItemType> = { (items, _) in items }
) {
View gist:4a12c832ce5921aa26d0e0b48f62b233
class SettingsControllerFacade {
private let bag = DisposeBag()
private let controller: SettingsControllerType
private let _settingGroups = PublishSubject<[SettingGroup]>()
init(
controller: SettingsControllerType
) {
View gist:e2e3e7344999498afa6cc5a1026bb1da
class ViewController: UIViewController {
class TestVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .green
}
}
View gist:470f9cf61e6f272dfb9cd7de70252858
class MenuView: NodeSubscriber<String> {
override func getSlice(_ state: AppState) -> SliceResult<String> {
return .stateSlice("")
}
override func makeNode(from slice: String) -> Node {
func setRoute(route: WorkspaceRoute) {
store.dispatch(SetRouteAction([route.rawValue]))
View gist:e8a19954ee1277a48e7bc199cf1cdbba
class EditSettingsVM {
struct Inputs {
let reload = PublishSubject<Void>()
let updateSetting = PublishSubject<(SettingKey, SettingValue)>()
let reset = PublishSubject<Void>()
let dismiss = PublishSubject<Void>()
let updateEnumSetting = PublishSubject<(SettingKey, EnumSettingValue)>()
}
View gist:3054bbcebde040935e45d5d2247d5bbe
import Foundation
struct Range: Hashable {
let start: Int
let end: Int
var count: Int {
return (end - start) + 1
}
View gist:b8fb99b5db5318f3d267e047c159fda1
class Solution {
var perf = 0
var perf2 = 0
var hitCache = 0
func longestPalindrome(_ s: String) -> String {
You can’t perform that action at this time.