Skip to content

Instantly share code, notes, and snippets.

View zxzxlch's full-sized avatar

Ben Cheah zxzxlch

View GitHub Profile
@zxzxlch
zxzxlch / Signal vs SignalProducer.swift
Last active October 4, 2019 08:21
Exploring the Signal and SignalProducer objects in ReactiveSwift 1.1
import Foundation
import ReactiveSwift
import Result
let a = MutableProperty<String>("")
let b = MutableProperty<String>("")
let c = MutableProperty<String>("")
// Signals are hot
let signalDisposable = Signal.combineLatest(a.signal, b.signal, c.signal)
@zxzxlch
zxzxlch / Learning ReactiveCocoa.md
Last active August 5, 2016 15:19
Using ReactiveCocoa 4.0
  • RAC4 breaks the concept of signals into two distinct types: SignalProducers and Signals. A SignalProducer is very similar to the old RACSignal; it does nothing until it is started. The developers changed the terminology from subscribed to started because it more accurately describes the state of the signal. For example, a SignalProducer could have multiple observers that are set up to receive events sent on the signal, but the signal won’t become active and the observers won’t see any events until it is started by something. A signal is started by calling start() on it.

  • The other new type is Signal. A Signal is like a firehose. You hook it up to a source, and events travel through it. There is no starting of a Signal, so you can’t use it to kick off work in the same way a SignalProducer can. Signals also can’t maintain any history. When something begins observing a Signal’s events, it w

{
"meta": {
"dataSource": "http://www.chas.sg/clinic_locator.aspx",
"lastUpdated": "2015-07-23T10:16:02.418Z",
"count": 1438
},
"data": [
{
"name": "115 Eastpoint Clinic & Surgery",
"address": "115 Bedok North Road, #01 - 301, Singapore - 460115",
@zxzxlch
zxzxlch / web_console_snippets.js
Last active August 29, 2015 14:25
Web console snippets
// Load jQuery
(function(){
var script = document.createElement('script');
script.type = "text/javascript";
script.src = "http://code.jquery.com/jquery-latest.min.js";
document.getElementsByTagName('head')[0].appendChild(script);
})();
// jQuery.noConflict();