Comments (4)
Hi,
I see how this can be improved, however and()
, or()
and not()
are too ambiguous names for functions/methods.
Maybe something like this:
combineLatest(mobileSignal, passwordSignal, smsCodeSignal)
.map( reduceUsing(.And) )
.bindTo( isEnabled(fetchCodeButton) )
Where reduceUsing
is a curried function which accepts the kind of operation to use (.And
or .Or
) and returns a function which in its turn accepts a tuple with booleans that comes from applying map
on the signal coming from combineLatest
.
In Swift 2.0 using generic type extensions and protocol extensions we can implement something cleaner, so for now I will leave it as it is.
Thanks!
from signalkit.
Im happy to tell you that in SignalKit 1.0.0 we now have all
and some
signal operations for signals of tuple type (Bool, Bool)
and (Bool, Bool, Bool)
Now you can write your example like this:
combineLatest(mobileSignal, passwordSignal, smsCodeSignal)
.all { $0 == true }
.bindTo(enabled: fetchCodeButton)
from signalkit.
Nice.
But what if I have 4 or more params to pass?
from signalkit.
You can combine them like this:
let signalA = ...
let signalB = ...
let signalC = ...
let signalD = ...
let signalAB = combineLatest(signalA, signalB).all { $0 == true }
let signalCD = combineLatest(signalC, signalD).all { $0 == true }
combineLatest(signalAB, signalCD)
.all { $0 == true }
.bindTo(enabled: button)
Or you can implement a free function combineLatest
similarly to the one included in SignalKit that accepts 4 signals and then add a extension to SignalType
protocol for the methods all
and some
for a signal of tuple type (Bool, Bool, Bool, Bool)
from signalkit.
Related Issues (18)
- Option to emit the initial observable value HOT 5
- OS X Support
- Rename `ControlSignal` to `UIControlSignal` HOT 1
- Aliases for `.all({ $0 })` and `.some({ $0 })` HOT 1
- Nested ObservableArray not calling the correct ArrayBindingObserver initialiser in .observe() HOT 2
- Support for `UIBarButtonItem` HOT 1
- KVO doesn't work HOT 6
- Undeclared CollectionChangeSet type in 3.0 release HOT 2
- Add `deinit` and propagated `dispose` method to `DisposableBag` class HOT 1
- Swift 3.0 compatibility HOT 8
- NotificationObserverTests.testDisposeOnDeinit() is failed with Swift 3 fork
- The correct way to do an "initial" sendNext to get combineLatestWith to work HOT 3
- how would i create a Timer signal HOT 2
- Swift 2.0 HOT 1
- ObservableArray HOT 1
- UIKit generic type extensions
- Pod doesn't include ObservableType HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from signalkit.