Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test asRxObservable() instead of createObservable() which is now deprecated #596

Merged
merged 1 commit into from Jan 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -104,7 +104,7 @@ storIOSQLite
.table("tweets")
.build())
.prepare()
.createObservable() // Get Result as rx.Observable and subscribe to further updates of tables from Query!
.asRxObservable() // Get Result as rx.Observable and subscribe to further updates of tables from Query!
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, here we literaly saying Get Result as rx.Observable 😄

So, I guess, new method name is okay :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe

.observeOn(mainThread()) // All Rx operations work on Schedulers.io()
.subscribe(tweets -> { // Please don't forget to unsubscribe
// Will be called with first result and then after each change of tables from Query
Expand Down Expand Up @@ -245,7 +245,7 @@ One of the main goals of `StorIO` — clean API for Humans which will be easy to
All `Query` objects are immutable, you can share them safely.

####Concept of Prepared Operations
You may notice that each Operation (Get, Put, Delete) should be prepared with `prepare()`. `StorIO` has an entity called `PreparedOperation<T>`, and you can use them to perform group execution of several Prepared Operations or provide `PreparedOperation<T>` as a return type of your API (for example in Model layer) and client will decide how to execute it: `executeAsBlocking()` or `createObservable()`. Also, Prepared Operations might be useful for ORMs based on `StorIO`.
You may notice that each Operation (Get, Put, Delete) should be prepared with `prepare()`. `StorIO` has an entity called `PreparedOperation<T>`, and you can use them to perform group execution of several Prepared Operations or provide `PreparedOperation<T>` as a return type of your API (for example in Model layer) and client will decide how to execute it: `executeAsBlocking()` or `asRxObservable()`. Also, Prepared Operations might be useful for ORMs based on `StorIO`.

You can customize behavior of every Operation via `Resolvers`: `GetResolver`, `PutResolver`, `DeleteResolver`.

Expand Down
14 changes: 7 additions & 7 deletions docs/StorIOContentResolver.md
Expand Up @@ -60,7 +60,7 @@ storIOContentResolver
.whereArgs("@artem_zin")
.build())
.prepare()
.createObservable() // Get Result as rx.Observable and subscribe to further updates of Uri from Query!
.asRxObservable() // Get Result as rx.Observable and subscribe to further updates of Uri from Query!
.observeOn(mainThread()) // All Rx operations work on Schedulers.io()
.subscribe(tweets -> { // Please don't forget to unsubscribe
// will be called with first result and then after each change of Uri from Query
Expand Down Expand Up @@ -90,7 +90,7 @@ storIOContentResolver
.uri(tweetsUri)
.build())
.prepare()
.createObservable()
.asRxObservable()
.take(1) // To get result only once and ignore further changes of this Uri
.observeOn(mainThread())
.subscribe(tweets -> {
Expand Down Expand Up @@ -132,7 +132,7 @@ storIOContentResolver
.put()
.object(tweet)
.prepare()
.executeAsBlocking(); // or createObservable()
.executeAsBlocking(); // or asRxObservable()
```

######Put multiple objects of some type
Expand All @@ -143,7 +143,7 @@ storIOContentResolver
.put()
.objects(tweets)
.prepare()
.executeAsBlocking(); // or createObservable()
.executeAsBlocking(); // or asRxObservable()
```

######Put `ContentValues`
Expand All @@ -155,7 +155,7 @@ storIOContentResolver
.contentValues(contentValues)
.withPutResolver(putResolver) // requires PutResolver<ContentValues>
.prepare()
.executeAsBlocking(); // or createObservable()
.executeAsBlocking(); // or asRxObservable()
```

`Put` Operation requires `PutResolver` which defines the behavior of `Put` Operation (insert or update).
Expand Down Expand Up @@ -198,7 +198,7 @@ storIOContentResolver
.delete()
.object(tweet)
.prepare()
.executeAsBlocking(); // or createObservable()
.executeAsBlocking(); // or asRxObservable()
```

######Delete multiple objects
Expand All @@ -209,7 +209,7 @@ storIOContentResolver
.delete()
.objects(tweets)
.prepare()
.executeAsBlocking(); // or createObservable()
.executeAsBlocking(); // or asRxObservable()
```

Delete Resolver
Expand Down
18 changes: 9 additions & 9 deletions docs/StorIOSQLite.md
Expand Up @@ -52,7 +52,7 @@ storIOSQLite
.table("tweets")
.build())
.prepare()
.createObservable() // Get Result as rx.Observable and subscribe to further updates of tables from Query!
.asRxObservable() // Get Result as rx.Observable and subscribe to further updates of tables from Query!
.observeOn(mainThread()) // All Rx operations work on Schedulers.io()
.subscribe(tweets -> { // Please don't forget to unsubscribe
// will be called with first result and then after each change of tables from Query
Expand Down Expand Up @@ -83,7 +83,7 @@ storIOSQLite
.table("tweets")
.build())
.prepare()
.createObservable()
.asRxObservable()
.take(1) // To get result only once and ignore further changes of this table
.observeOn(mainThread())
.subscribe(tweets -> {
Expand All @@ -103,7 +103,7 @@ storIOSQLite
.args("artem_zin")
.build())
.prepare()
.createObservable();
.asRxObservable();
```

######Customize behavior of `Get` Operation with `GetResolver`
Expand Down Expand Up @@ -140,7 +140,7 @@ storIOSQLite
.put()
.object(tweet)
.prepare()
.executeAsBlocking(); // or createObservable()
.executeAsBlocking(); // or asRxObservable()
```

######Put multiple objects of some type
Expand All @@ -151,7 +151,7 @@ storIOSQLite
.put()
.objects(tweets)
.prepare()
.executeAsBlocking(); // or createObservable()
.executeAsBlocking(); // or asRxObservable()
```

######Put `ContentValues`
Expand All @@ -163,7 +163,7 @@ storIOSQLite
.contentValues(contentValues)
.withPutResolver(putResolver) // requires PutResolver<ContentValues>
.prepare()
.executeAsBlocking(); // or createObservable()
.executeAsBlocking(); // or asRxObservable()
```

`Put` Operation requires `PutResolver` which defines the behavior of `Put` Operation (insert or update).
Expand Down Expand Up @@ -208,7 +208,7 @@ storIOSQLite
.delete()
.object(tweet)
.prepare()
.executeAsBlocking(); // or createObservable()
.executeAsBlocking(); // or asRxObservable()
```

######Delete multiple objects
Expand All @@ -219,7 +219,7 @@ storIOSQLite
.delete()
.objects(tweets)
.prepare()
.executeAsBlocking(); // or createObservable()
.executeAsBlocking(); // or asRxObservable()
```

Delete Resolver
Expand Down Expand Up @@ -252,7 +252,7 @@ storIOSQLite
.affectsTables("tweets") // optional: you can specify affected tables to notify Observers
.build())
.prepare()
.executeAsBlocking(); // or createObservable()
.executeAsBlocking(); // or asRxObservable()
```

Several things about `ExecSql`:
Expand Down
Expand Up @@ -30,7 +30,7 @@ public void verifyBehavior() {
.first();

verify(preparedOperation, times(1)).executeAsBlocking();
verify(preparedOperation, times(0)).createObservable();
verify(preparedOperation, times(0)).asRxObservable();

assertThat(actualMapResult).isEqualTo(expectedMapResult);
}
Expand Down
Expand Up @@ -37,7 +37,7 @@ public void shouldExecuteAsBlockingAfterSubscription() {
.first();

verify(preparedOperation, times(1)).executeAsBlocking();
verify(preparedOperation, times(0)).createObservable();
verify(preparedOperation, times(0)).asRxObservable();

assertThat(actualResult).isEqualTo(expectedResult);
}
Expand Down
Expand Up @@ -45,7 +45,7 @@ public void deleteByQueryObservable() {
.delete()
.byQuery(deleteQuery)
.prepare()
.createObservable();
.asRxObservable();
}

@Test
Expand Down Expand Up @@ -84,7 +84,7 @@ public void deleteObjectsObservable() {
.objects(articles)
.withDeleteResolver(ArticleMeta.DELETE_RESOLVER)
.prepare()
.createObservable();
.asRxObservable();
}

@Test
Expand Down Expand Up @@ -121,7 +121,7 @@ public void deleteObjectObservable() {
.object(article)
.withDeleteResolver(ArticleMeta.DELETE_RESOLVER)
.prepare()
.createObservable();
.asRxObservable();
}

@Test
Expand Down
Expand Up @@ -67,7 +67,7 @@ public void getCursorAsObservable() {
.build())
.withGetResolver(mock(GetResolver.class))
.prepare()
.createObservable();
.asRxObservable();
}

@Test
Expand All @@ -80,7 +80,7 @@ public void getListOfObjectsAsObservable() {
.build())
.withGetResolver(ArticleMeta.GET_RESOLVER)
.prepare()
.createObservable();
.asRxObservable();
}

@Test
Expand All @@ -93,7 +93,7 @@ public void getObjectAsObservable() {
.build())
.withGetResolver(ArticleMeta.GET_RESOLVER)
.prepare()
.createObservable();
.asRxObservable();
}

@Test
Expand Down
Expand Up @@ -69,7 +69,7 @@ public void putObjectObservable() {
.object(article)
.withPutResolver(ArticleMeta.PUT_RESOLVER)
.prepare()
.createObservable();
.asRxObservable();
}

@Test
Expand Down Expand Up @@ -106,7 +106,7 @@ public void putCollectionOfObjectsObservable() {
.objects(articles)
.withPutResolver(ArticleMeta.PUT_RESOLVER)
.prepare()
.createObservable();
.asRxObservable();
}

@Test
Expand Down Expand Up @@ -142,7 +142,7 @@ public void putContentValuesObservable() {
.contentValues(contentValues)
.withPutResolver(putResolverForContentValues)
.prepare()
.createObservable();
.asRxObservable();
}

@Test
Expand Down Expand Up @@ -179,7 +179,7 @@ public void putContentValuesIterableObservable() {
.contentValues(contentValuesList)
.withPutResolver(putResolverForContentValues)
.prepare()
.createObservable();
.asRxObservable();
}

@Test
Expand Down
Expand Up @@ -79,7 +79,7 @@ public void deleteByQueryAsObservable() {
.uri(TestItem.CONTENT_URI)
.build())
.prepare()
.createObservable()
.asRxObservable()
.toBlocking()
.first();

Expand Down Expand Up @@ -164,7 +164,7 @@ public void deleteObjectExecuteAsBlocking() {
}

@Test
public void deleteObjectCreateObservable() {
public void deleteObjectasRxObservable() {
TestSubscriber<Changes> changesTestSubscriber = new TestSubscriber<Changes>();

storIOContentResolver
Expand All @@ -187,7 +187,7 @@ public void deleteObjectCreateObservable() {
.delete()
.object(testItem)
.prepare()
.createObservable()
.asRxObservable()
.toBlocking()
.first();

Expand Down Expand Up @@ -298,7 +298,7 @@ public void deleteObjectsAsObservable() {
.delete()
.objects(singletonList(testItem))
.prepare()
.createObservable()
.asRxObservable()
.toBlocking()
.first();

Expand Down
Expand Up @@ -110,7 +110,7 @@ public void getCursorAsObservableOnlyInitialValue() {
.uri(TestItem.CONTENT_URI)
.build())
.prepare()
.createObservable()
.asRxObservable()
.take(1)
.subscribe(cursorTestSubscriber);

Expand Down Expand Up @@ -153,7 +153,7 @@ public void getListOfObjectsAsObservableOnlyInitialValue() {
.uri(TestItem.CONTENT_URI)
.build())
.prepare()
.createObservable()
.asRxObservable()
.take(1)
.subscribe(listTestSubscriber);

Expand Down Expand Up @@ -373,7 +373,7 @@ public void getExistedObjectExecuteAsObservable() {
.whereArgs("value")
.build())
.prepare()
.createObservable()
.asRxObservable()
.take(1);

TestSubscriber<TestItem> testSubscriber = new TestSubscriber<TestItem>();
Expand Down Expand Up @@ -411,7 +411,7 @@ public void getNonExistedObjectExecuteAsObservable() {
.whereArgs("some value")
.build())
.prepare()
.createObservable()
.asRxObservable()
.take(1);

TestSubscriber<TestItem> testSubscriber = new TestSubscriber<TestItem>();
Expand Down Expand Up @@ -517,7 +517,7 @@ public void getOneExistedObjectTableUpdate() {
.whereArgs("value")
.build())
.prepare()
.createObservable()
.asRxObservable()
.take(2);

TestSubscriber<TestItem> testSubscriber = new TestSubscriber<TestItem>();
Expand Down Expand Up @@ -553,7 +553,7 @@ public void getOneNonexistedObjectTableUpdate() {
.whereArgs("value")
.build())
.prepare()
.createObservable()
.asRxObservable()
.take(2);

TestSubscriber<TestItem> testSubscriber = new TestSubscriber<TestItem>();
Expand Down
Expand Up @@ -108,7 +108,7 @@ public void insertContentValuesAsObservable() {
.contentValues(cv)
.withPutResolver(testItemContentValuesPutResolver)
.prepare()
.createObservable()
.asRxObservable()
.toBlocking()
.first();

Expand Down Expand Up @@ -215,7 +215,7 @@ public void updateContentValuesAsObservable() {
.contentValues(testItem.toContentValues())
.withPutResolver(testItemContentValuesPutResolver)
.prepare()
.createObservable()
.asRxObservable()
.toBlocking()
.first();

Expand Down Expand Up @@ -319,7 +319,7 @@ public void insertObjectAsObservable() {
.put()
.object(testItem)
.prepare()
.createObservable()
.asRxObservable()
.toBlocking()
.first();

Expand Down Expand Up @@ -426,7 +426,7 @@ public void updateObjectAsObservable() {
.put()
.object(testItem)
.prepare()
.createObservable()
.asRxObservable()
.toBlocking()
.first();

Expand Down