From 9ff24944ba1698068d5966aa3cd6a09836c4a1f4 Mon Sep 17 00:00:00 2001 From: izumin5210 Date: Tue, 24 Nov 2015 08:52:46 +0900 Subject: [PATCH 1/4] Fix sample app name --- examples/todomvc/src/main/res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/todomvc/src/main/res/values/strings.xml b/examples/todomvc/src/main/res/values/strings.xml index 2335029..36ad552 100644 --- a/examples/todomvc/src/main/res/values/strings.xml +++ b/examples/todomvc/src/main/res/values/strings.xml @@ -1,6 +1,6 @@ - Droidux sample - Droidux sample + TodoMVC + TodoMVC Add new task From 47f849be69a03766189668c05d55b1375fd32e79 Mon Sep 17 00:00:00 2001 From: izumin5210 Date: Tue, 24 Nov 2015 09:09:55 +0900 Subject: [PATCH 2/4] Update README --- README.md | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f1c9b97..5df3a0c 100644 --- a/README.md +++ b/README.md @@ -33,12 +33,11 @@ Add to your project build.gradle file: ```groovy buildscript { dependencies { - classpath "com.android.databinding:dataBinder:1.0-rc3" classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' } } -apply plugin: 'com.android.databinding' +apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' dependencies { @@ -47,6 +46,9 @@ dependencies { } ``` +And also you need to setup [Data Binding][databinding]. + + ## Usage ### Quick example @@ -204,6 +206,64 @@ store.dispatch(new ClearCountAction()).subscribe(); // [next counter]: 0 ``` +### Undo / Redo + +```java +@Undoable +@Reducer(TodoList.class) +class TodoListReducer { + @Dispatchable(AddTodoAction.class) + public TodoList addTodo(TodoList state, AddTodoAction action) { + // ... + } + + @Dispatchable(CompleteTodoAction.class) + public TodoList completeTodo(TodoList state, CompleteTodoAction action) { + // ... + } +} + +class TodoList extends ArrayList implements UndoableStore { + @Override + public TodoList clone() { + // ... + } + + public static Todo { + // ... + } +} + +class AddTodoAction extends Action{ + // ... +} + +class CompleteTodoAction extends Action{ + // ... +} + + +DroiduxTodoListStore store = new DroiduxTodoListStore.Builder() + .addReducer(new TodoListReducer()) + .addInitialState(new TodoList()) + .build(); + +store.dispatch(new AddTodoAction("item 1")).subscribe(); // ["item 1"] +store.dispatch(new AddTodoAction("item 2")).subscribe(); // ["item 1", "item 2"] +store.dispatch(new AddTodoAction("item 3")).subscribe(); // ["item 1", "item 2", "item 3"] +store.dispatch(new CompleteTodoAction("item 2")).subscribe(); // ["item 1", "item 3"] +store.dispatch(new AddTodoAction("item 4")).subscribe(); // ["item 1", "item 3", "item 4"] + +store.dispatch(new UndoAction(DroiduxTodoListStore.class)).subscribe(); +// => ["item 1", "item 3"] + +store.dispatch(new UndoAction(DroiduxTodoListStore.class)).subscribe(); +// => ["item 1", "item 2", "item 3"] + +store.dispatch(new RedoAction(DroiduxTodoListStore.class)).subscribe(); +// => ["item 1", "item 3"] +``` + ### Async action ```java @@ -224,9 +284,18 @@ class FetchTodoListAction extends Action { new FetchTodoAction().fetch().flatMap(store::dispatch).subscribe(); ``` +#### Bindable methods + +* `Store#getState()` +* `Store#isUndoalble()` // when the reducer is annotated with `@Undoable` +* `Store#isRedoalble()` // when the reducer is annotated with `@Undoable` + + ## Examples * [TodoMVC](https://github.com/izumin5210/Droidux/tree/master/examples/todomvc) +* [Todos with Undo](https://github.com/izumin5210/Droidux/tree/master/examples/todos-with-undo) + ## License From 862e2a0a40c15b1cca0f60e4ad537b7e419ed73b Mon Sep 17 00:00:00 2001 From: izumin5210 Date: Tue, 24 Nov 2015 09:10:33 +0900 Subject: [PATCH 3/4] v0.3.0 --- README.md | 4 ++-- build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5df3a0c..de92f89 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,8 @@ apply plugin: 'com.android.application' apply plugin: 'com.neenbedankt.android-apt' dependencies { - compile 'info.izumin.android:droidux:0.2.0' - apt 'info.izumin.android:droidux:0.2.0' + compile 'info.izumin.android:droidux:0.3.0' + apt 'info.izumin.android:droidux:0.3.0' } ``` diff --git a/build.gradle b/build.gradle index db83626..b85a555 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ task clean(type: Delete) { ext { def versionMajor = 0 - def versionMinor = 2 + def versionMinor = 3 def versionPatch = 0 def versionBuild = 0 From 1c3b933ca272405dad1343c0148c7a8fc82270b8 Mon Sep 17 00:00:00 2001 From: izumin5210 Date: Tue, 24 Nov 2015 09:12:36 +0900 Subject: [PATCH 4/4] Fix sectioning --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index de92f89..e5763fa 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,7 @@ class FetchTodoListAction extends Action { new FetchTodoAction().fetch().flatMap(store::dispatch).subscribe(); ``` -#### Bindable methods +### Bindable methods * `Store#getState()` * `Store#isUndoalble()` // when the reducer is annotated with `@Undoable`