Giter VIP home page Giter VIP logo

Comments (8)

yankodimitrov avatar yankodimitrov commented on June 8, 2024 1

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.

evgeniyd avatar evgeniyd commented on June 8, 2024

For reference, this fork is an attempt to migrate the project to Swift 3

from signalkit.

yankodimitrov avatar yankodimitrov commented on June 8, 2024

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.

shergin avatar shergin commented on June 8, 2024

Yay!!1
I believe there is noting bad in bumping major version!

from signalkit.

yankodimitrov avatar yankodimitrov commented on June 8, 2024

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.

shergin avatar shergin commented on June 8, 2024

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.

shergin avatar shergin commented on June 8, 2024

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.

yankodimitrov avatar yankodimitrov commented on June 8, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.