Skip to content

Commit

Permalink
Merge pull request #10 from mvarnagiris/moved_views_to_package
Browse files Browse the repository at this point in the history
Moved views to package
  • Loading branch information
mvarnagiris authored Mar 9, 2018
2 parents fb62c6d + 5ec2445 commit f125317
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 20 deletions.
13 changes: 0 additions & 13 deletions src/main/kotlin/com/mvcoding/mvp/DataView.kt

This file was deleted.

18 changes: 18 additions & 0 deletions src/main/kotlin/com/mvcoding/mvp/views/DataView.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.mvcoding.mvp.views

import com.mvcoding.mvp.O
import com.mvcoding.mvp.Presenter
import com.mvcoding.mvp.RxSchedulers
import com.mvcoding.mvp.trampolines


interface DataView<in T> : Presenter.View {
fun showData(data: T)
}

fun <INPUT, DATA, VIEW : DataView<DATA>> O<INPUT>.loadData(view: VIEW,
dataSource: (INPUT) -> O<DATA>,
schedulers: RxSchedulers = trampolines): O<DATA> =
switchMap { dataSource(it).subscribeOn(schedulers.io) }
.observeOn(schedulers.main)
.doOnNext { view.showData(it) }
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
package com.mvcoding.mvp
package com.mvcoding.mvp.views

import com.mvcoding.mvp.O
import com.mvcoding.mvp.Presenter
import com.mvcoding.mvp.RxSchedulers
import com.mvcoding.mvp.trampolines

interface ErrorView<in ERROR> : Presenter.View {
fun showError(error: ERROR)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
package com.mvcoding.mvp
package com.mvcoding.mvp.views

import com.mvcoding.mvp.O
import com.mvcoding.mvp.Presenter
import com.mvcoding.mvp.RxSchedulers
import com.mvcoding.mvp.trampolines

interface LoadingView : Presenter.View {
fun showLoading()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.mvcoding.mvp
package com.mvcoding.mvp.views

import com.mvcoding.mvp.O
import com.mvcoding.mvp.RxSchedulers
import com.mvcoding.mvp.trampolines
import io.reactivex.Observable

interface RefreshableView {
Expand Down
1 change: 1 addition & 0 deletions src/test/kotlin/com/mvcoding/mvp/BehavioursTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mvcoding.mvp

import com.mvcoding.mvp.views.*
import com.nhaarman.mockitokotlin2.*
import io.reactivex.Observable
import io.reactivex.subjects.PublishSubject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mvcoding.mvp
package com.mvcoding.mvp.views

import com.mvcoding.mvp.O
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.verify
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mvcoding.mvp
package com.mvcoding.mvp.views

import com.mvcoding.mvp.O
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.verify
import io.reactivex.observers.TestObserver
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mvcoding.mvp
package com.mvcoding.mvp.views

import com.mvcoding.mvp.O
import com.nhaarman.mockitokotlin2.inOrder
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.verify
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mvcoding.mvp
package com.mvcoding.mvp.views

import com.mvcoding.mvp.O
import com.nhaarman.mockitokotlin2.mock
import com.nhaarman.mockitokotlin2.whenever
import io.reactivex.observers.TestObserver
Expand Down

0 comments on commit f125317

Please sign in to comment.