Skip to content

Instantly share code, notes, and snippets.

View simonpang's full-sized avatar

Simon Pang simonpang

  • Hong Kong
View GitHub Profile
@simonpang
simonpang / gist:5301093
Created April 3, 2013 13:14
Dreaming of promise event handling v3
- (id)init
{
if (self = [super initNibName:nil bundle:nil]) {
[[[[self whenViewDidLoad] then:^(id result, NSError *error) {
return [self.loginButton whenTouchDown];
}] then:^(id result, NSError *error) {
@simonpang
simonpang / gist:b08353a13eb776c7639f
Last active August 29, 2015 14:14
Network Request Library in Cocoa Style (Command pattern)
@interface DNSession : NSObject<NSCopying, NSCoding>
@property (copy) NSString *authToken;
@property (copy) NSString *userIdentifier;
+ (instancetype)defaultSession;
- (instancetype)initWithConfiguration:(NSDictionary *)options;
@end
@simonpang
simonpang / MVMUM.swift
Last active November 10, 2017 09:39
MVMUM Architecture (i.e. View ViewModel UseCase Model)
MVMUM Architecture (View ViewModel UseCase Model)
V > VM > UC > M ( i.e. direction of dependency)
<= direct of flow control
=> increasing relevant to domain (i.e. plain object)
<= increasing relevant to framework/environment (i.e. platform objects with side effect e.g. native GUI, database)
Example: (user login screen)
@simonpang
simonpang / Application.swift
Last active February 2, 2018 08:54
Debug UIEvent
override func sendEvent(_ event: UIEvent) {
NSLog("sendEvent \(event)")
super.sendEvent(event)
var vc = keyWindow!.rootViewController!
while vc.presentedViewController != nil {
vc = vc.presentedViewController!
}
// Find hit view
if let view = vc.view {
@simonpang
simonpang / ViewController.m
Last active May 30, 2018 08:15
Dynamic collection view cell size using auto-layout
//
// ViewController.m
// DemoScrolling
//
// Created by Simon Pang on 30/5/2018.
// Copyright © 2018 Simon Pang. All rights reserved.
//
#import "ViewController.h"
@simonpang
simonpang / RxSwiftMultithreadTests.swift
Last active November 27, 2018 07:22
RxSwift multi-threading tests
//
// RxSwiftMultithreadTests.swift
// GoodNotesTests
//
// Created by Simon Pang on 27/11/2018.
// Copyright © 2018 Time Base Technology Limited. All rights reserved.
//
import XCTest
import RxSwift