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
| /** | |
| * Forks a nullable into a non nullable, | |
| * | |
| * This differs from the if else expression | |
| * which is thread unsafe and doesn't guarantee | |
| * the non nullability even if the value was validated as non null | |
| * by the if expression (due to concurrency) | |
| * NOTE: need to check this :D, probably i need to use contracts like the std to assure what | |
| * i said above | |
| * |
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 java.lang.ref.WeakReference | |
| // It doesn't matter for the receiver which one is the received argument | |
| typealias LateBoxList<R> = List<LateMapBox<*, R>> | |
| fun <T, R> Iterable<T>.mapAsLateBox(mapper: (T) -> R): List<LateMapBox<T, R>> { | |
| return this.map { LateMapBox(it, mapper) } | |
| } | |
| /** |
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 android.os.Bundle | |
| // Dunno if there's a better way to extend both bundle and intents, but | |
| // you probably can extend intents in the same way | |
| fun Bundle.putEnum(key:String, enum: Enum<*>){ | |
| putString(key, enum.name) | |
| } | |
| inline fun <reified T: Enum<T>> Bundle.getEnum(key:String): T { |
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
| //An memoize fn would be good to use here. | |
| const getService = (serviceName) => angular.element(document.body).injector().get(serviceName); | |
| export default new Proxy({}, { | |
| get (target, prop) { | |
| return getService(prop); | |
| } | |
| }); |
NewerOlder