Giter Site home page Giter Site logo

ashfurrow / functionalreactivepixels Goto Github PK

View Code? Open in Web Editor NEW
701.0 31.0 94.0 152 KB

A demonstration of how to use FRP with ReactiveCocoa in an iOS context using the 500px API.

Home Page: https://leanpub.com/iosfrp

License: MIT License

Objective-C 99.17% Ruby 0.83%

functionalreactivepixels's Introduction

500px shut down their API, which this repo relied on. The code here will no longer work. Sorry about that – it's a shame, too, since their API was something that made 500px special and now it's gone.

A demonstration of how to use FRP with ReactiveCocoa in an iOS context using the 500px API.

This is code to accompany my book.

Installing

Clone the repo and run pod install from the repo's directory to install the required pods.

git clone https://github.com/ashfurrow/FunctionalReactivePixels.git
cd FunctionalReactivePixels
pod install

Please do not click the "Download ZIP" button on this page.

Please don't go all creepy with my consumer key.

functionalreactivepixels's People

Contributors

andrask avatar andypple avatar appscommopensource avatar ashfurrow avatar jspahrsummers avatar kastiglione avatar tlewisii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

functionalreactivepixels's Issues

Why you can get rid of prepareForReuse?

In section "Revisiting FunctionalReactivePixels", there is “We can abstract away the need to use the prepareForReuse method altogether by replacing creating a new property on FRPCell”. However, why you don't even need the "takeUntil:self.rac_prepareForReuseSignal" to get the reusable cell work?

500px is deactivated the API

  • (RACSignal *)importPhotos {
    return [[[[[self requestPhotoData] deliverOn:[RACScheduler mainThreadScheduler]] map:^id(NSData *data) {
    id results = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
    .....
    }

(lldb) po results
{
error = "Application is deactivated, please contact us by email: [email protected].";
status = 403;
}

so that I cant fetch the photos, haha

crashed when u slide quickly from current photo to previous in full-size-photo view.

quickly slide to next photo before the current photo displays, then slide back, crashed

log msg:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Signal <RACDynamicSignal: 0x17423f3a0> name: is already bound to key path "fullsizedData" on object <FRPPhotoModel: 0x17409fe50>, adding signal <RACDynamicSignal: 0x1704214e0> name: is undefined behavior'

Run in iPhone5s, iOS 8

i am new to RAC, could u tell me what happened?

Unable to compile

I'm getting the following error when I try to compile:

ld: library not found for -lPods-FRP
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've tried both cloning the github repo and using cocoa pods as well as compiling from the zip file you provided.

More Opportunities to Use RAC

Since this is a project demo'ing what's possible with ReactiveCocoa, I don't mind going heavy-handed on the pedagogy. Any ideas for opportunities I'm missing out? I'm particularly interested in examples of where to use RACCommand.

Bad scrolling performance

I tried the app on an iPhone 4S and the scrolling performance on the main screen is quite shabby. I guess the issues arise when cell recycling happens. Can it be that too much work is done on the main thread?

64 bit problems

Unknown type name 'ffi_status'
Unknown type name 'ffi_cif'

Login System

Create a mandatory (?) login system so users can vote. Or not mandatory. I 'unno. Thoughts?

Cannot run profiler

When trying to profile, lots of errors appear. I guess the configuration needs to be updated for this scenario too.

Break Apart Chained Signals

Some of the chained signals are pretty complex – breaking them apart into intermediate variables might be helpful to readers.

NSURLConnection+RACSupport

+rac_sendAsynchronousRequest: can replace the direct use of NSURLConnection.

Of course, doing so would require more chaining (to implement parsing, and eventually deliver to the main thread). The method also returns a cold signal, so it might require replaying, or else refactoring the call points to ensure there's only ever one subscription.

Swift is not supported for static libraries.

Hello Ash Furrow,

I followed the instruction of your book.

Write pod 'ReactiveCocoa'
run pod install

This error message shows up.

Check dependencies

Swift is not supported for static libraries.

The latest ReactiveCocoa's version I fetched is 3.0.0

How can I make it compile?

Error handlings

What about errors handlings, how can I inform controller, that some error has occured? With fetching images, or model creation?

Send one photo at a time on +importPhotos

Instead of performing complicated mapping on the list of photos and then sending the transformed list, one photo can be sent on the signal at a time.

This allows the transformations to be applied to the signal directly, and more obviously emphasizes the notion of a stream of values over time.

Although probably not relevant to this example, this also makes pagination more transparent, like in octokit.objc.

When to retain RACDelegateProxy?

In the section "Revisiting FunctionalReactivePixels", there's a NOTE that delegate objects must be retained. However, "collectionViewDelegate" is retained while "RACDelegateProxy *viewControllerDelegate = [[RACDelegateProxy alloc] initWithProtocol:@protocol(FRPFullSizePhotoViewControllerDelegate)];" is not retained.

RACSubjects in asynchronous code should be RACReplaySubject

Every RACSubject that's used for an asynchronous operation should actually be RACReplaySubject, or else it's possible for the following race condition to occur:

  1. Subject created
  2. Asynchronous operation started
  3. Asynchronous operation completes very quickly and returns its results
  4. Subject returned
  5. Caller subscribes to subject, but nothing ever happens (since the results were sent before it was ready)

This is important enough that it should be present in the initial code samples (IMO), not introduced in a refactoring chapter.

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.