Git Product home page Git Product logo

parsespike's Introduction

parseSpike

##Introduction

An example of two different ways to abstract out Parse calls (in a class called ParseApi). In both cases, we use the thread blocking call for fetching objects from parse.

In one of the parseApi methods (fetchActivityTypesUsingDelegate:), we use GCD and call notify the delegate (activityManager) on the main thread when the results on returned. When the delegate receives the results, it updates a public property someActivities. Meanwhile, the VC is using ReactiveCocoa's RACObserve to look for changes in someActivities. When received, the UI updates. This approach is an example of confining ReactiveCocoa to just one class (the VC).

The second method in parseApi (fetchActivityTypes) again calls Parse using a thread-blocking call and returns the results as an Array. The ActivityManager method (fetchActivityTypes) that calls this method does so in a GCD queue and returns the results as a RACSignal to the VC that invoked the fetchActivityTypes method. When the VC subscribes to the signal and the data is returned via that signal, the UI is updated.

In both cases, the main thread is not blocked by the Parse call. So why not just use a callback or fetch in background call with Parse? Well, we are experimenting with making it more testable.

##Getting Started

The project requires CocoaPods to install a few dependencies (Reactive Cocoa, Facebook, OCMock). So, be sure to run pod install from the commandline within the root folder of the project.

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.