-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathNSButton.swift
More file actions
28 lines (23 loc) · 849 Bytes
/
NSButton.swift
File metadata and controls
28 lines (23 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//
// NSButton+ReactiveExtensions.swift
// FuzzMeasure
//
// Created by Christopher Liscio on 2016-01-11.
// Copyright © 2016 SuperMegaUltraGroovy, Inc. All rights reserved.
//
import Foundation
import ReactiveSwift
import ReactiveCocoa
import Result
extension NSButton {
public var rex_stateAction: Action<NSButton, Int, NoError> {
return associatedObject(self, key: &stateActionKey) { _ in Action<NSButton, Int, NoError> { SignalProducer(value: $0.state) } }
}
public var rex_states: Signal<Int, NoError> {
let cocoaAction = associatedObject(self, key: &stateCocoaActionKey) { CocoaAction($0.rex_stateAction) { $0 as! NSButton } }
rex_action.value = cocoaAction
return rex_stateAction.values
}
}
private var stateActionKey: UInt8 = 0
private var stateCocoaActionKey: UInt8 = 0