-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brian Egan
committed
Feb 9, 2016
1 parent
3d938f4
commit 14cacc7
Showing
8 changed files
with
27 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
examples/counter/src/main/java/com/brianegan/bansa/counter/ApplicationModule.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
examples/counter/src/main/java/com/brianegan/bansa/counter/StoreModule.java
This file was deleted.
Oops, something went wrong.
32 changes: 18 additions & 14 deletions
32
examples/counter/src/main/kotlin/com/brianegan/bansa/counter/Application.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
package com.brianegan.bansa.counter | ||
|
||
import com.brianegan.bansa.counter.ApplicationModule | ||
import com.brianegan.bansa.counter.StoreModule | ||
import dagger.ObjectGraph | ||
import com.brianegan.bansa.Action | ||
import com.brianegan.bansa.Store | ||
import com.brianegan.bansa.createStore | ||
import uy.kohesive.injekt.Injekt | ||
import uy.kohesive.injekt.InjektMain | ||
import uy.kohesive.injekt.api.InjektRegistrar | ||
import uy.kohesive.injekt.api.fullType | ||
import uy.kohesive.injekt.api.get | ||
|
||
class Application : android.app.Application() { | ||
var objectGraph: ObjectGraph? = null | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
instance = this | ||
objectGraph = ObjectGraph.create(ApplicationModule(this), StoreModule()) | ||
companion object : InjektMain() { | ||
override fun InjektRegistrar.registerInjectables() { | ||
addSingleton( | ||
fullType<Store<ApplicationState, Action>>(), | ||
createStore(ApplicationState(), applicationReducer)); | ||
} | ||
} | ||
|
||
companion object { | ||
private var instance: Application? = null | ||
val store = Injekt.get(fullType<Store<ApplicationState, Action>>()) | ||
|
||
fun getObjectGraph(): ObjectGraph? { | ||
return instance?.objectGraph | ||
} | ||
override fun onCreate() { | ||
super.onCreate() | ||
store.dispatch(CounterActions.INIT) // Initialize the store | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,4 @@ fun <A : Action, S : State, VM> connect( | |
view(mapStoreToViewModel(store)) | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters