Comments (8)
You are right its more cleaner as an initializer parameter, so I refactored it to:
let name = Signal<String>(atomic: true)
Probably because SignalValue
is a bad name so I renamed it to SignalProperty
. 😅
The Idea is that SignalProperty
have an initial/current value and sends it to new observers right away, so you don't have to send an initial value as with the basic Signal
:
// with SignalProperty
let name = SignalProperty<String>(value: "John", atomic: true)
name.bindTo(textIn: nameLabel).disposeWith(bag) // nameLabel.text is now "John"
// with Signal
let name = Signal<String>(atomic: true)
name.bindTo(textIn: nameLabel).disposeWith(bag)
name.send("John") // we have to send the initial value after we have signal observers
Also I added macOS
target 🎉
Thanks!
from signalkit.
For reference, this fork is an attempt to migrate the project to Swift 3
from signalkit.
I will work on it in the coming weeks.
I would like to remove some unnecessary parts like the CollectionEvent
, UITableView
and UICollectionView
bindings.
Also the versioning came out of control 😅 if I introduce the API breaking changes by following the semantic versioning the next version should be 5.0. What do you think should I just bump the version to 4.1?
If you have any suggestions, please share them here.
Much appreciated!
from signalkit.
Yay!!1
I believe there is noting bad in bumping major version!
from signalkit.
Im working on it on the SignalKit-5.0 branch.
I refactored the Signal
and SignalValue
to be simple non-thread safe classes by default.
Usually those are intended to create a binding between ViewModel and the View on the main thread.
If the ViewModel is doing some async work on a background thread it will have the option to send the result to the Signal on the main thread.
Of course we can create a thread safe Signal
and SignalValue
by passing a Lock
protocol implementation (there is a default public MutexLock
implementation) or we can use the class factory method .atomic()
and .atomic(value: T)
:
// non-thread safe
let age = Signal<Int>()
let name = Signal<String>(value: "John")
// thread safe
let age = Signal<Int>(lock: MutexLock())
let name = SignalValue<String>(value: "John", lock: MutexLock())
// thread safe
let age = Signal<Int>.atomic()
let name = SignalValue<String>.atomic(value: "John")
Hope to hear your feedback 😃
from signalkit.
Yay! 🎉
I always prefer having default implementation simple as possible, so I think this is the right move!
I also slightly prefer to have Signal<Int>(atomic: true)
instead of Signal<Int>.atomic()
... I believe that it is more Swifty style.
But, feel free to ignore my advices because... I don't know the difference between Signal
and SignalValue
.
Awesome work, Yanko! Thank you!
from signalkit.
Wow! That is great that you designate this functionality (SignalProperty) as a first class citizen of SignalKit! Really, these are different and equally important concepts and we have to have them both!
Personally, I slightly prefer to name SignalProperty
as something that extends Signal
concept, so it should have a name pattern <Adjective>+"Signal"
like... PersistentSignal
. But, again, as an author, you have to know better. 😄
from signalkit.
I like the idea.
Here are some explorations for a signal that reacts to new observers by sending them its current value:
ReactiveSignal
StoredSignal
StoredSignal
sounds good, but yes naming things is hard 😄
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
- and() or() not() for SignalKit.Signal<(A, B, C)> HOT 4
- 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.