Git Product home page Git Product logo

rxpaper's Introduction

Contact ๐Ÿ“ซ

You can reach me via:

rxpaper's People

Contributors

cesarferreira avatar diegorodriguezaguila avatar drewcarlson 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

rxpaper's Issues

No ability to have multiple instances of RxPaper

RxPaper contains 2 static fields to hold the instances of the current RxPaper and custom book you'd be using.

private static RxPaper mRxPaper;
private static String sCustomBook;

There are 2 issues with this setup which both relate to having multiple custom books (or preferably, instances of RxPaper)

Problem 1:

RxPaper.book("custom-book1").read(...)
RxPaper.book("custom-book2").read(...)
RxPaper.book("custom-book1").read(...)

This will instantiate 3 instances on RxPaper (3x overriding the same static field). So if i use 2 custom books i will create a lot of useless instances.

Problem 2:

I can not have multiple classes which each have a separate RxPaper with a custom book because of the above. The last class create will determine which custom book the will all share.

getAllKeys() + hasBook() implementation leads to unwanted behaviour

public Observable<List<String>> getAllKeys() {

    return Observable.create(new Observable.OnSubscribe<List<String>>() {
        @Override
        public void call(Subscriber<? super List<String>> subscriber) {

            if (!subscriber.isUnsubscribed()) {

                try {
                    List<String> keys;
                    if (hasBook()) {
                        keys = Paper.book(mCustomBook).getAllKeys();
                    } else {
                        keys = Paper.book().getAllKeys();
                    }
                    subscriber.onNext(keys);
                } catch (Exception e) {
                    subscriber.onError(new UnableToPerformOperationException("Can't collect all keys"));
                }

                subscriber.onCompleted();
            }
        }
    });
}

private static boolean hasBook() {
return !TextUtils.isEmpty(mCustomBook);
}

In my implementation I work with multiple books.
Problem: I don't know at runtime if a book has entries or not.
If I call "getAllKeys()" at a time where a book is empty I get all keys from default book.

I will overcome this problem by not using default book. However, I suggest to just return zero keys if a custom book is empty and not fall back to default book keys.

Initializing Paper too much times?

What is the need to pass a context to RxPaper.with(..) method, which initilalizes Paper.init(...) for every call?, In Paper docs states that Paper.init(context); must be called only once in Application.onCreate(...). I'm temporary workarounding it by creating another initializer, but I think the context is not necesary in any way.

Observable.create vs Observable.defer

This is not really an issue, more of a question. As most people advocate against using Observable.create unless really needed. link

What are your opinions on this and why do you use Observable.create in RxPaper?

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.