Reactive extensions to Cocoa frameworks, built on top of ReactiveSwift.
ReactiveSwift offers composable, declarative and flexible primitives that are built around the grand concept of streams of values over time. These primitives can be used to uniformly represent common Cocoa and generic programming patterns that are fundamentally an act of observation.
For more information about the core primitives, see ReactiveSwift.
ReactiveCocoa wraps various aspects of Cocoa frameworks with the declarative ReactiveSwift primitives.
-
UI Bindings
UI components expose
BindingTarget
s, which accept bindings from any kind of streams of values via the<~
operator.// Bind the `name` property of `person` to the text value of an `UILabel`. nameLabel.reactive.text <~ person.name
Note: You'll need to import ReactiveSwift as well to make use of the
<~
operator.Controls and User Interactions
Interactive UI components expose
Signal
s for control events and updates in the control value upon user interactions.A selected set of controls provide a convenience, expressive binding API for
Action
s.// Update `allowsCookies` whenever the toggle is flipped. preferences.allowsCookies <~ toggle.reactive.isOnValues // Compute live character counts from the continuous stream of user initiated // changes in the text. textField.reactive.continuousTextValues.map { $0.characters.count } // Trigger `commit` whenever the button is pressed. button.reactive.pressed = CocoaAction(viewModel.commit)
Declarative Objective-C Dynamism
Create signals that are sourced by intercepting Objective-C objects, e.g. method call interception and object deinitialization.
// Notify after every time `viewWillAppear(_:)` is called. let appearing = viewController.reactive.trigger(for: #selector(UIViewController.viewWillAppear(_:))) // Observe the lifetime of `object`. object.reactive.lifetime.ended.observeCompleted(doCleanup)
Expressive, Safe Key Path Observation
Establish key-value observations in the form of
SignalProducer
s andDynamicProperty
s, and enjoy the inherited composability.// A producer that sends the current value of `keyPath`, followed by // subsequent changes. // // Terminate the KVO observation if the lifetime of `self` ends. let producer = object.reactive.producer(forKeyPath: #keyPath(key)) .take(during: self.reactive.lifetime) // A parameterized property that represents the supplied key path of the // wrapped object. It holds a weak reference to the wrapped object. let property = DynamicProperty<String>(object: person, keyPath: #keyPath(person.name))
But there are still more to be discovered and introduced. Read our in-code documentations and release notes to find out more.
ReactiveCocoa supports macOS 10.9+, iOS 8.0+, watchOS 2.0+, and tvOS 9.0+.
If you use Carthage to manage your dependencies, simply add ReactiveCocoa to your
Cartfile
:github "ReactiveCocoa/ReactiveCocoa" ~> 10.1
If you use Carthage to build your dependencies, make sure you have added
ReactiveCocoa.framework
andReactiveSwift.framework
to the "Linked Frameworks and Libraries" section of your target, and have included them in your Carthage framework copying build phase.If you use CocoaPods to manage your dependencies, simply add ReactiveCocoa to your
Podfile
:pod 'ReactiveCocoa', '~> 10.1'
If you use Swift Package Manager, simply add ReactiveCocoa as a dependency of your package in
Package.swift
:.package(url: "https://github.com/ReactiveCocoa/ReactiveCocoa.git", branch: "master")
- Add the ReactiveCocoa repository as a submodule of your application’s repository.
- Run
git submodule update --init --recursive
from within the ReactiveCocoa folder. - Drag and drop
ReactiveCocoa.xcodeproj
andCarthage/Checkouts/ReactiveSwift/ReactiveSwift.xcodeproj
into your application’s Xcode project or workspace. - On the “General” tab of your application target’s settings, add
ReactiveCocoa.framework
andReactiveSwift.framework
to the “Embedded Binaries” section. - If your application target does not contain Swift code at all, you should also
set the
EMBEDDED_CONTENT_CONTAINS_SWIFT
build setting to “Yes”.
If you need any help, please visit our GitHub issues or Stack Overflow. Feel free to file an issue if you do not manage to find any solution from the archives.
ReactiveCocoa is expected to declare library ABI stability when Swift rolls out resilience support in Swift 5. Until then, ReactiveCocoa will incrementally adopt new language features.
rockemsockem's People
Forkers
wangjhstc mralexgray zakdances honda41 wabbitslayer sethkontny fabitzhe hawk-eye rksterr walterliu dgodfrey206 windhorn psing008 shababa santoshveluguri jmhome danetheory jellyz flox35 wanghaiquan bdacode tecneva knightwupz linhaolun andyfiore prince7811 rockyspade satizvlr jkorty iamdeveloper bklaib21 mdabbagh88 complexityclass jobssteve dodohu loveeer17 mybdgw chaddar adaptiveintelligence chinafengping joesantana yasoob willsen888 795bf814gw1 github-zhang dohywa34 abhishekvas abeclaudius rohinikumar4073 jmoscatiello syamin jeremytio soneyt vasu504 garybyrd uchuugaka runt18 isabella232rockemsockem's Issues
Disconnect from JS does not work
RocketSockem works perfectly for receiving and sending messages from JavaScript client. But I'm not able to disconnect the JS Client on Safari - on Chrome it takes a very long time to be disconnected.
// Server _server = [[RSMServer alloc] init]; _server.port = 19487; _server.interface = @"localhost"; [_server.webSockets subscribeNext:^(RSMWebSocket *socket) { [socket.messages subscribeNext:^(id x) { [socket sendMessage:x]; }]; }]; [_server start:nil];
// Client ws = new WebSocket("ws://localhost:19487"); ... ws.close();
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.