-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/crashes' into develop
- Loading branch information
Showing
8 changed files
with
112 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,6 @@ class DeleteAMomentActivity : AppCompatActivity() { | |
) | ||
) | ||
) | ||
) | ||
)() | ||
} | ||
} |
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
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
31 changes: 31 additions & 0 deletions
31
.../src/commonMain/kotlin/com/hadisatrio/libs/kotlin/foundation/event/SkippingEventSource.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2022 Hadi Satrio | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.hadisatrio.libs.kotlin.foundation.event | ||
|
||
import com.badoo.reaktive.observable.Observable | ||
import com.badoo.reaktive.observable.skip | ||
|
||
class SkippingEventSource( | ||
private val count: Number, | ||
private val origin: EventSource | ||
) : EventSource { | ||
|
||
override fun events(): Observable<Event> { | ||
return origin.events().skip(count.toLong()) | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
.../commonTest/kotlin/com/hadisatrio/libs/kotlin/foundation/event/SkippingEventSourceTest.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (C) 2022 Hadi Satrio | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.hadisatrio.libs.kotlin.foundation.event | ||
|
||
import com.badoo.reaktive.subject.publish.PublishSubject | ||
import com.badoo.reaktive.test.observable.test | ||
import com.hadisatrio.libs.kotlin.foundation.event.fake.FakeEvent | ||
import com.hadisatrio.libs.kotlin.foundation.event.fake.FakeEventSource | ||
import io.kotest.matchers.collections.shouldHaveSize | ||
import kotlin.test.Test | ||
|
||
class SkippingEventSourceTest { | ||
|
||
@Test | ||
fun `Skips N elements of the given stream`() { | ||
val count = 10 | ||
val origin = FakeEventSource(PublishSubject()) | ||
val source = SkippingEventSource(count, origin) | ||
|
||
val events = source.events().test() | ||
repeat(count * 2) { origin.produce(FakeEvent()) } | ||
|
||
events.values.shouldHaveSize(count) | ||
} | ||
} |