Giter VIP home page Giter VIP logo

rrreactivenetworking's Introduction

RRReactiveNetworking

License: MIT Platform

Managing Nested Asynchronous Callbacks in Objective-C using ReactiveCocoa by AFNetworking

Requirements

Use of the following Cocoapods is required:

Installation

Manually

  1. Download the project.
  2. Add RRApiManager.h & RRApiManager.m with necessary files in your project.
  3. Congratulations!

Usage example

A RACSignal should wrap an operation with an asynchronous callback block.

The last signal to run should call subscribeNext for receiving output values. If no output values are available, subscribeNext can be replaced by subscribeCompleted or subscribeError.

Any intermediate step is defined by flattenMap. The parameter in flattenMap corresponds to the data from the next signal. It also takes a return value, which is the subsequent signal to run. The two signals are written top-down and are executed top-down.

We don’t want to strongly retain self: in ARC, we introduce __weak. Also, the extra square brackets at start and end are ugly in Objective-C’s implementation of functional reactive programming.

@weakify(self);

NSDictionary *param = @{@"key": @"test"};
[[[[[RRApiManagerShared postAPICallURL:API_URL header:nil param:param]
flattenMap:^(id responseOfPostAPI) {
    NSLog(@"%@",responseOfPostAPI);
    return [RRApiManagerShared getAPICallURL:API_URL header:nil];
}]
subscribeOnBackgroundAndDeliverOnMainThread]
subscribeNext:^(id responseGetAPI) {
    NSLog(@"%@",responseGetAPI);
} error:^(NSError * error) {
    NSLog(@"%@",error.localizedDescription);
}] rac_deallocDisposable];

To run the project, clone the repo, and run pod install from the RRReactiveNetworking directory first.

Contribute

We would love you for the contribution to RRReactiveNetworking, check the LICENSE file for more info.

License

RRReactiveNetworking is available under the MIT license. See the LICENSE file for more info.

rrreactivenetworking's People

Contributors

rahul-mayani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

carabina

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.