Skip to content

Instantly share code, notes, and snippets.

View johnlahboo's full-sized avatar
💭
hard working

John Lah Boo johnlahboo

💭
hard working
View GitHub Profile
var express = require('express')
var app = express()
app.get('/footballPlayers', function(req, res) {
var json_string = {"players":[
{"name":"Messi", "goals":8},
{"name":"Ronaldo", "goals":22},
{"name":"Costa", "goals":20},
{"name":"Neymar", "goals":13},
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
@IBOutlet weak var resultLabel: UILabel!
var viewModel: ViewModel!
let disposeBag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
class ViewModel {
var numberVariable = Variable<String?>(nil)
var isEvenObservable: Observable<String>!
init () {
isEvenObservable = numberVariable.asObservable()
.map {number in
guard let numberTemp = number else {return "Invalid"}
guard let numberIsNumber = Int(numberTemp) else {return (numberTemp + " is not number")}
return (numberIsNumber % 2 == 0) ? numberTemp + " is Even" : numberTemp + " is Odd"
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
target 'AAA' do
pod 'RxSwift'
pod 'RxCocoa'
end
class ViewModel {
var numberVariable = Variable<String?>(nil)
var isEvenObservable: Observable<String>!
}