This file contains hidden or 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
fun Any.prettyPrint(): String { | |
val sb = StringBuilder() | |
val chars = toString().toCharArray() | |
var level = 0 | |
var inString = false | |
var inArray = false | |
for (char in chars) { | |
when (char) { | |
'(' -> { | |
if (!inString) { |
This file contains hidden or 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
interface Middleware<S> { | |
Object dispatch(StateProvider<S> stateProvier, Object action, Dispatcher next); | |
interface StateProvider<S> { | |
S getState(); | |
} |
This file contains hidden or 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
interface Middleware<S> { | |
Object dispatch(Store<S> store, Object action, Dispatcher next); | |
} |
This file contains hidden or 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
interface Dispatcher { | |
Object dispatch(Object action); | |
} |
This file contains hidden or 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
package clean.news.adapter | |
import android.content.Context | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import clean.news.R | |
import clean.news.core.entity.Item.ListType | |
import clean.news.inject.ModuleContext | |
import clean.news.ui.item.list.ItemListKey.ItemListModule |
This file contains hidden or 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
import rx.Observable | |
import java.util.LinkedHashMap | |
class HashStreamMap<K> : LinkedHashMap<K, Observable<*>>, MutableStreamMap<K> { | |
constructor() : super() | |
constructor(initialCapacity: Int) : super(initialCapacity) | |
constructor(initialCapacity: Int, loadFactor: Float) : super(initialCapacity, loadFactor) |
This file contains hidden or 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
class DaggerService(private val rootComponent: Any) : ServicesFactory() { | |
override fun bindServices(services: Binder) { | |
val key = services.getKey<Any>() | |
if (key !is WithComponent) { | |
return | |
} | |
val parent = services.getService<Any>(NAME) ?: rootComponent | |
val component = key.createComponent(parent) |
This file contains hidden or 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
@Plumbed(MyViewIntent.class) | |
class MyView extends FrameLayout { | |
@Inject | |
public MyViewIntent viewIntent; | |
@Out("red") | |
public Observable<Integer> red; | |
@Out("green") | |
public Observable<Integer> green; | |
@Out("blue") |
This file contains hidden or 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
remote.getIt(foo) // Observable<Bar> | |
//.doOnNext { local.saveIt(bar).toBlocking().single() } // "Interrupted while waiting for subscription to complete" on errors. | |
.flatMap { bar -> local.saveIt(bar).map { bar } } // Hacky, but makes saving part of stream and won't throw exceptions due to blocking observable. |
This file contains hidden or 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
import com.sun.jdi.InvalidTypeException | |
import java.util.LinkedHashSet | |
import kotlin.properties.ReadWriteProperty | |
import kotlin.reflect.KProperty | |
public object Properties { | |
fun observable<T>(initialValue: T): ReadWriteProperty<Any?, T> { | |
return ObservableProperty(initialValue) | |
} | |
} |
NewerOlder