Skip to content

Instantly share code, notes, and snippets.

🤔
Always Thinking

Eric De Wildt EricDw

🤔
Always Thinking
Block or report user

Report or block EricDw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@EricDw
EricDw / Program.kt
Created Feb 15, 2019
KotlinFunctionsProgram
View Program.kt
@file:Suppress("KDocUnresolvedReference")
package com.examples.standardfunctions
import androidx.annotation.Nullable
import java.util.*
import java.util.function.Function
// region Person
@EricDw
EricDw / Pipelines.kt
Last active Nov 22, 2018
Added an output channel.
View Pipelines.kt
class PipelineBuilder<I, O>(
actorScope: ActorScope<I>,
outputChannel: Channel<O>
) : ActorScope<I> by actorScope {
}
@EricDw
EricDw / Pipelines.kt
Created Nov 22, 2018
Using the by keywaord to delegate functionality to a passed parameter.
View Pipelines.kt
class PipelineBuilder<I>(
actorScope: ActorScope<I>
) : ActorScope<I> by actorScope {
}
@EricDw
EricDw / Pipelines.kt
Created Nov 22, 2018
Using the Pipeline builder as the receiver.
View Pipelines.kt
fun <I, O> CoroutineScope.pipeline(init: PipelineBuilder.() -> Unit): Pipeline<I, O> {
}
@EricDw
EricDw / Pipelines.kt
Last active Nov 22, 2018
The start of the context object used in the pipeline function.
View Pipelines.kt
class PipelineBuilder()
@EricDw
EricDw / Pipelines.kt
Created Nov 21, 2018
The starting point for our pipeline DSL function.
View Pipelines.kt
fun <I, O> CoroutineScope.pipeline(init: suspend PipelineBuilder<I, O>.() -> Unit): Pipeline<I, O> {
@EricDw
EricDw / Pipelines.kt
Last active Nov 21, 2018
The starting function for the pipeline DSL function.
View Pipelines.kt
fun <I, O> CoroutineScope.pipeline(): Pipeline<I, O> {
}
@EricDw
EricDw / PipelineDSLTest.kt
Last active Nov 21, 2018
The setup code for making a pipeline and a demonstration of how it should work inside.
View PipelineDSLTest.kt
private lateinit var intToStringPipeline: Pipeline<Int, String>
@Before
fun setUp() {
intToStringPipeline = CoroutineTestingScope.pipeline() {
for (number in channel) {
send { number.toString() }
}
}
}
@EricDw
EricDw / Pipelines.kt
Created Nov 21, 2018
An interface defining the external behavior of a pipeline.
View Pipelines.kt
interface Pipeline<I, O> : SendChannel<I>, ReceiveChannel<O>
@EricDw
EricDw / PipelineDSLTest.kt
Created Nov 21, 2018
A Unit Test demostrating how I expected the Pipeline Interface to look.
View PipelineDSLTest.kt
@Test
fun given_1_when_send_then_string_of_1() {
// Arrange
val input: Int = 1
val expected: String = "1"
lateinit var actual: String
// Act
CoroutineTestingScope.launch {
intToStringPipeline.send(input)
You can’t perform that action at this time.