Example:
import androidx.compose.runtime.* | |
import kotlinx.coroutines.CoroutineScope | |
@Stable | |
internal class Event<T>(val value: T) | |
class MutableEventQueue<T> | |
internal constructor(): EventQueue<T>() { | |
private val events = mutableListOf<Event<T>>() | |
private val nextEventAsState = mutableStateOf<Event<T>?>(null) |
/* | |
* MIT License | |
* | |
* Copyright (c) 2022 Albert Chang | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is |
import androidx.compose.ui.Modifier | |
import androidx.compose.ui.composed | |
import androidx.compose.ui.draw.drawBehind | |
import androidx.compose.ui.graphics.Color | |
import androidx.compose.ui.graphics.Paint | |
import androidx.compose.ui.graphics.drawscope.drawIntoCanvas | |
import androidx.compose.ui.graphics.toArgb | |
import androidx.compose.ui.unit.Dp | |
import androidx.compose.ui.unit.dp |
/* | |
Copyright 2020 Cedric Kring. | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, |
#!/sbin/openrc-run | |
command="/root/bin/pia-wg.sh" | |
CONFIGDIR="${CONFIGDIR:-/var/cache/pia-wg}" | |
CONFIG="${CONFIG:-/etc/pia-wg/pia-wg.conf}" | |
extra_started_commands="reload" | |
depend() { |
pipeline { | |
agent { node { label 'swarm-ci' } } | |
environment { | |
TEST_PREFIX = "test-IMAGE" | |
TEST_IMAGE = "${env.TEST_PREFIX}:${env.BUILD_NUMBER}" | |
TEST_CONTAINER = "${env.TEST_PREFIX}-${env.BUILD_NUMBER}" | |
REGISTRY_ADDRESS = "my.registry.address.com" | |
SLACK_CHANNEL = "#deployment-notifications" |
State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?
There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.
Here I present a composable pattern for pure state machiness with effects,
public class RxSchedulerHook { | |
private ISRxSchedulerHook() { | |
// no instances | |
} | |
/** | |
* this makes sure that when we run the tests all of RxJava | |
* operates on a single thread (Scheduler.immediate) | |
*/ |