- Redux is a library that manages states. Based on functional principals it solves a problem of data flow in an interesting way.
- In an app your data should have a unidirectional flow. The data flows forward, it never comes back.
- A data with changed properties is not same data (Autovalue), it can be a different copy object.
- In redux, you pass an
action
, Areducer
listens to action and changesstore
connects bothacion
andreducer
actoin
: Must have a string, can optionaly have any type of payload.reducer
: Must return a state, it can never throw error or return undefined thing.- In any error case or un-recognized action, it should return previous state passed.
store
: Allows to subscribe/unsubscribe updates, can read current state at any time and sends actions to reducers
This file contains 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
#!/usr/bin/env -S deno run -A | |
import { ensureFileSync } from "https://deno.land/std@0.224.0/fs/mod.ts"; | |
import { parseArgs } from "jsr:@std/cli/parse-args"; | |
import { Anthropic } from "npm:@anthropic-ai/sdk"; | |
import * as log from "jsr:@std/log"; | |
import { extname } from "jsr:@std/path"; | |
import { TextBlock } from "npm:@anthropic-ai/sdk"; | |
const aiPrompt = ` |
This file contains 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.text.DateFormat | |
import java.text.SimpleDateFormat | |
import org.gradle.internal.os.OperatingSystem; | |
task(debugSomething) { | |
doLast { | |
println OperatingSystem.properties | |
} |
This file contains 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.squareup.moshi.Json | |
data class DbSchema(@field:Json(name = "formatVersion") val formatVersion: Int? = 0, @field:Json( | |
name = "database") val database: Database? = Database()) | |
data class Database(@field:Json(name = "version") val version: Int = 0, @field:Json(name = "identityHash") val identityHash: String? = "", @field:Json( | |
name = "entities") val entities: List<Entity?>? = listOf(), @field:Json(name = "setupQueries") val setupQueries: List<String?>? = listOf()) |
This file contains 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
inline fun <T> Cursor.delegate(key: String? = null, | |
crossinline getter: Cursor.(Int) -> T): ReadOnlyProperty<Any?, T> { | |
return object : ReadOnlyProperty<Any?, T> { | |
override fun getValue(thisRef: Any?, property: KProperty<*>): T { | |
val s = key ?: property.name | |
return getter(getColumnIndex(s)) | |
} | |
} |
This file contains 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.content.Context | |
import android.graphics.Bitmap | |
import android.graphics.drawable.Drawable | |
import android.support.annotation.DrawableRes | |
import android.support.v4.content.ContextCompat | |
import android.widget.ImageView | |
import com.bumptech.glide.DrawableTypeRequest | |
import com.bumptech.glide.RequestManager | |
import com.bumptech.glide.load.Transformation | |
import com.bumptech.glide.load.engine.DiskCacheStrategy |
This file contains 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
suspend fun downloadFile(url: String, | |
downloadFile: File, | |
downloadProgressFun: (bytesRead: Long, contentLength: Long, isDone: Boolean) -> Unit) { | |
async(CommonPool) { | |
val request = with(Request.Builder()) { | |
url(url) | |
}.build() | |
val client = with(OkHttpClient.Builder()) { | |
addNetworkInterceptor { chain -> |
This file contains 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 LoginActivity : AppCompatActivity() { | |
@Inject lateinit var loginPresenter: LoginPresenter | |
lateinit var binding: ActivityLoginBinding | |
val loginViewModel: LoginViewmodel by lazy { | |
LoginViewmodel() | |
} |
This file contains 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
sealed class ApiResponse<T> { | |
class Loading<Unit> : ApiResponse<Unit>() | |
class Nothing<Unit> : ApiResponse<Unit>() | |
class NoInternet<Unit> : ApiResponse<Unit>() | |
class ConnectionError<Unit>(val throwable: Throwable, val error: String) : ApiResponse<Unit>() | |
data class Success<T>(val response: Response<T>, | |
val data: T? = response.body(), | |
val headers: Headers? = response.headers()) : ApiResponse<T>() | |
data class SuccessData<T>(val data: T?) : ApiResponse<T>() |
This file contains 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
<scheme name="io17" version="142" parent_scheme="Darcula"> | |
<option name="FONT_SCALE" value="1.0" /> | |
<metaInfo> | |
<property name="created">2017-11-13T20:44:16</property> | |
<property name="ide">AndroidStudio</property> | |
<property name="ideVersion">3.0.0.18</property> | |
<property name="modified">2017-11-29T13:01:35</property> | |
<property name="originalScheme">Darcula</property> | |
</metaInfo> | |
<option name="EDITOR_FONT_SIZE" value="16" /> |
NewerOlder