Skip to content

Instantly share code, notes, and snippets.

View scottroemeschke's full-sized avatar

Scott Roe-Meschke scottroemeschke

  • Snap
  • Denver, Colorado
View GitHub Profile
// Some syntax, might be a bit off, written quickly :D
/**
* The question, (as I'm hearing it): how to write unit tests for my view controller when Kotlin classes are closed by default?
**/
//------------------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------------

Keybase proof

I hereby claim:

  • I am scottroemeschke on github.
  • I am scottroemeschke (https://keybase.io/scottroemeschke) on keybase.
  • I have a public key ASDDvJY8fuJkxd2g4R9shAbVA-UFvYGpXwBf0YJFx0V9qgo

To claim this, I am signing this object:

Inside config obj:
- Feature flags values are limited to true/false?
- Keys are immutable across environments.
- In Blinker Api: Keys come from? (Consul? Code? Variety of sources?)
- Do we want to add timestamp or something to flag so clients
can be set to invalidate all before a given time or something like this?
fun stuff() {
val cal = Calendar.getInstance()
val date = cal.time (is a Date) // synthetic property for getTime() which returns a date
//but somehow at runtime this is a long (calendar has protected long called time)
val realDate = cal.getTime() //get ide warning to use the property syntax instead, but at run-time this is actually a date
methodThatTakesADate(date)
}
fun methodThatTakesADate(date: Date) {
println(date)
package com.thinksincode.prboard;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.constraint.Group;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ProgressBar;
fun examples() {
val disposables = CompositeDisposable()
disposables += Maybe.just("User")
.subscribeEmitNull {
if (it != null) println(it)
}
@scottroemeschke
scottroemeschke / basicrxlessdataobserving.kt
Last active March 21, 2018 05:16
context: https://www.reddit.com/r/androiddev/comments/85y4j2/mvp_with_a_single_presenter/ Not supposed to be the best implementation of some home-grown observer pattern, but just demonstrating you don't have to use Rx as a beginner to understand or develop reactive systems.
data class User(val firstName: String, val lastName: String)
interface UserObserver {
fun onUserUpdated(user: User)
}
//could also do this user observer as just a function/lambda with or without type alias
//typealias UserObserver = (User) -> Unit
interface UserRepo {
//basic interface start something to get single with eventual result (or quit)
//call quit to cancel/quit the workflow prematurely
interface Workflow<C, Q> {
fun start(): Single<WorkflowResult<C,Q>>
fun quit()
}
//completed or quit, this comes down the single as the result of the workflow
//would be very high level business results (with potential data)
sealed class WorkflowResult<C,Q> {
@scottroemeschke
scottroemeschke / EasySingleActivityAbstractions.kt
Last active March 21, 2018 04:56
Basic example showing how to pull stuff out of activity, simplify terrible android apis, include them in unit tests, and how single activity will make this sort of thing easier and less "glue"/maintainence/lifecycle-management code. context: https://www.reddit.com/r/androiddev/comments/82vhbe/what_is_the_future_of_best_practices_between/
//when you have a single activity it's very easy to build abstractions, hook into those, and simplify lifecycle issues,
//navigation (subscreens, backbutton, new flows etc), permissions/fingerprint other annoying APIs
//simple psuedo-code ish examples
sealed class PermissionResult {
data class Successful(val permission: String): PermissionResult()
data class Failed(val failureReason: FailureReason): PermissionResult()
enum class FailureReason {
@scottroemeschke
scottroemeschke / HelixBrainstorming.kt
Created February 25, 2018 02:33
Brainstorming a reactive flow similar to spotify mobius with some key changes
//Top level Tag Interfaces - May not be needed
interface HelixState //Immutable State/Data for UI/Helix
interface HelixIntent //User intents/actions from UI
interface HelixEvent //External events (Internet connected, low battery warning, etc)
interface HelixEffect //Triggered effects (HTTP/DB calls, business logic/app layer updates etc)
interface HelixCommand //Commands to trigger effects (MakeLoginRequest, SchedulePendingNotification)
interface HelixDestination //Navigation/Routing location (URL/URI, changing sub-screens or top level flows/features)
typealias BeginProvider<State, Command> = () -> Begin<State, Command>
typealias UpdateGenerator<State, Input, Command, Destination> = (State, Input) -> Update<State, Command, Destination>