reactkit / reactkit Goto Github PK
View Code? Open in Web Editor NEWSwift Reactive Programming.
License: MIT License
Swift Reactive Programming.
License: MIT License
Hi there,
CocoaPods lists 0.9.0 as the latest version. Would you mind pushing the latest tag when you get a free moment?
Love the project!
Is it possible to keep a property of 1 object synchronised with a property of another, while avoiding the 'infinite echo' situation with naive 2-way observations?
I'm trying to make a model object's property synchronised with a text field. I can create a stream of the property values to bind to the value of the text field, but then I'd somehow need to make the stream of text field values set the model's property without triggering the previous binding.
In one class I have these
public var nickname: NSString?
private var nicknameSignal: Stream<NSString?>!
public init(){
nicknameSignal = KVO.stream(self, "nickname")
|> asStream(NSString?)
nicknameSignal ~> println
}
In another class I have this code which observes on a textfield and sends the signal to nickname.
(account, "nickname") <~ nicknameFieldSignal!
However, the result from println is always nil. But if I map the value of nicknameSignal to the forced unwrap version first then the signal prints the correct value.
nicknameSignal = KVO.stream(self, "nickname")
|> map { $0! }
|> asStream(NSString?)
Currently swift/1.2 branch is running for Xcode6.3-beta (Swift 1.2) support.
It would be good to have a signal which executes only one time, and then it returns same result.
I understand it's not 'pure', but it is really useful to build applications, specially when you deal with network requests and avoiding duplicate work.
Do you have any suggestions on how to best achieve this with current API?
Currently working on swift/2.0
branch ๐ฑ
ErrorType
or generic Error
instead of NSError
#32repeat
, catch
)Hi,
I can't seem to be able to create a signal using the init closure.. whenever I create a signal it automatically goes into failure block.. here's a test signal:
let signal = Signal<String> { (progress, fulfill, reject, configure) -> Void in
progress("pffft, lets see")
println("created signal successfully")
}.progress({ (oldProgress, newProgress) -> Void in
println(newProgress)
})
.success { value -> Void in
println("singal is finished")
}.failure({ (error, isCancelled) -> Void in
println(error!.localizedDescription)
println("is cancelled: \(isCancelled)")
})
error!.localizedDescription
is printing: Signal=DefaultSignal is cancelled via deinit.
Am I doing something wrong? or is there something wrong in the framework (which I doubt actually)?
Podspec is pull outdated SwiftTask for dependency
When I'm trying to call carthage update --use-submodules
it returns error:
*** Fetching ReactKit
*** Fetching SwiftTask
*** Checking out SwiftTask at "2.6.3"
*** Checking out ReactKit at "0.7.1"
fatal: Not a git repository (or any of the parent directories): .git
The Carfile is pretty simple:
github "ReactKit/ReactKit"
First of all great work. Your project looks really awesome and must have been hard work to bring out such a wonderful project.
But want I would like to know is the following.
Why did you do it if there is something like Reactive Cocoa out there?
What sets it apart from Reactive Cocoa?
Could you not have contributed to Reactive Cocoa and bring in your own ideas?
What are your plans in the future? Will you be able to continue maintenance and support of Reactkit?
Just a few questions off of my head and I would really be happy to have these anwered.
Others might be interested in the answers as well.
Take care
Lovely work, @inamiy. Even though I've been a huge RAC fan for a long time, now I'm planning to use ReactKit for my next app (specially for how it focuses a lot in making KVO smooth).
However, there's something from RAC that I think would make a great addition here: ignoreNil
. As simple as it is, filter { $0 != nil }
isn't as compelling and generates stress when reading code. Plus I find this to be a repetitive pattern in my codebases, so I think it's a good idea to have a specific function for it within the framework.
What do you think? I'm up for writing this function myself and PR once I'm done ๐
Hi!
Again thanks for you work on the lib :) I'm still learning Reactive Programming, and I wonder if you could assist me on how to do something I encounter all the time.
Let's say you have one stream, which does some asynchronous work, gives a successful value and fulfills.
And then somewhere else you want to continue doing something after this, with another stream.
If you connect both streams with flatMap, the second stream will terminate as well, which is not what I intended.
What do you recommend to use in this case?
Thanks!
Currently Streams supply generic values, but the error is cocoa NSError.
I think it would be more future-proof and user friendly to support generic errors. Many times when dealing with Swift codes, the errors are simple enums.
What do you think?
The ReactKit framework (built with Carthage) includes a Frameworks folder containing the Swift standard library, which prevents apps from being submitted to the app store:
Deleting the Frameworks folder resolves the issue, but it would be nice to not have this step.
I'll submit a pull request if I can figure out the reason, but after a bit of digging I came up empty.
let stream = Stream.once("foo").ownedBy(self)
println <~ stream
println <~ stream
I wonder if it's correct behaviour, that println will be called once. If I now did something like:
(label,"text") <~ stream
The label would never change.
How is this different from RxSwift?
Here's working fine
self.buttonSignal = self.button.buttonSignal("OK")
But, When I try...
self.buttonSignal = self.button.buttonSignal()
I got...
ViewController.swift:87:58: Missing argument for parameter #1 in call
So the question is that possible to "not send" any arg?
Thanks
I want a simple stream:
Stream.sequence([1,2,3,4])
|> map { (n: Int) -> Void in
return n * 2
}
|> react { // use of unresolved identifier 'react'
println($0)
}
But it said "use of unresolved identifier 'react'". I was confused how to apply react
?
Also is it possible to construct a stream and dispatch change manually? E.g.
let stream = Stream<String>()
stream.map { ... }
.react { ... }
// later on
stream.dispatch("change")
I like the simplicity of this project but it is incomplete without support for combining operations like zip
, combineLatest
, which are pretty essential. The any
function looks like it's merge
(which could be used as the basis for these other combining functions), but in other libraries any
is a boolean operation. The different definitions for map
should be named semantically like scan
, flatMap
, etc.
Do you have plans to support more of the operations from Rx? I am not smart enough to do the work myself
Maybe it's intentional but I'm used to ReactiveCocoa where the KVO signals take the initial value when they are setup.
Thus when you setup the signal it'll fire the signal the first time by pulling the value.
currently ReactKit is not working in swift 3
Why aren't you supporting cocoapods? all major libraries are supporting cocoapods.. it would add up to the awesome library you have here!
It just requires use_framework
, I don't see why not?
I have a use case where each signal has a different data type. After some transformation is done to each signal, they will be sent out together as network request. Since their types are different I can't put them in one array. As it stands, array operators like merge2All require all signals to be of the same type. Sure I can cast them to AnyObject but that's just way too verbose, and I will have to cast them back in order to send over network.
I think it's better to use tuple instead of array, in which case any types are allowed.
So far I have tried using ReactKit 0.7.0, 0.6.1 and 0.6.0. They all failed to build with an error because of SwiftTask when using the command carthage update
. The error comes down to these two lines in my build log:
/Users/UserName/Projects/ProjectName/Carthage/Checkouts/ReactKit/Carthage/Checkouts/SwiftTask/SwiftTask/SwiftTask.swift:758:5: error: use of unresolved identifier 'objc_sync_enter'
objc_sync_enter(object)
^
/Users/UserName/Projects/ProjectName/Carthage/Checkouts/ReactKit/Carthage/Checkouts/SwiftTask/SwiftTask/SwiftTask.swift:760:5: error: use of unresolved identifier 'objc_sync_exit'
objc_sync_exit(object)
^
What's the proper way of installing this framework? I tried Cocoapods but it seems to be a much older version than what I find here.
ReactKit Swift 5 not support?
pod install xcworkspace can't build
How would I create a signal for invocation of an arbitrary selector? I'd like to react to touch events on a UIView, and because they are neither gestures nor control events, I'd like to generate signals every time the message 'sendEvent:' is sent to the view's window and filter and react to that.
I really like the tidy API BTW.
env: Xcode Version 7.0.1 (7A1001)
following along the home page:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let button = UIButton(frame: CGRectMake(40, 40, 40, 40))
self.view.addSubview(button)
button.backgroundColor = UIColor.redColor()
let buttonStream = button.buttonStream("OK")
^{ print($0) } <~ buttonStream
}
but nothing happened
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.