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.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import androidx.annotation.LayoutRes | |
import androidx.recyclerview.widget.DiffUtil | |
import androidx.recyclerview.widget.ListAdapter | |
import androidx.recyclerview.widget.RecyclerView | |
fun <T, VH : ListAdapterBuilder.ViewHolder<T>> createListAdapter( | |
init: ListAdapterBuilder<T, VH>.() -> Unit |
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 arrow.core.Either | |
import arrow.core.left | |
import arrow.core.right | |
class JsonUser | |
class User | |
fun JsonUser.toUser(): User = throw RuntimeException() | |
sealed class UserQueryErrors { |
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 arrow.core.Option | |
class NonZeroInt private constructor(val value: Int) { | |
companion object { | |
operator fun invoke(x: Int): Option<NonZeroInt> = | |
if (x == 0) Option.empty() else Option.just(NonZeroInt(x)) | |
fun get(x: NonZeroInt): Int = x.value | |
} | |
} |
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 {combineReducers} from 'redux' | |
const todos = (state = [], {type, payload}) => { | |
switch(type) { | |
case LIST_TODOS: | |
return payload | |
case ADD_TODO: | |
return {...state, payload} | |
case TOGGLE_TODO: | |
return state.map(todo => todo.id === payload ? {...todo, completed: !todo.completed} : todo) |
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
const initialState = { | |
todos: [], | |
filter: 'all', | |
isLoading: false | |
} | |
export default function(state = initialState, action) { | |
switch (action.type) { | |
case FETCH_TODOS: | |
return {...state, isLoading: true} |
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
const restaurant = { | |
clientRequests: { | |
"1": { | |
"drinks": [ | |
{id: 3, name: "Beer", quantity: 4} | |
] | |
}, | |
"2": { | |
"appetizers": [ | |
{id: 1, name: "Onion rings", quantity: 2}, |
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
const store = { | |
partyMembers: [] | |
} | |
const addPersonToParty = (person) => ({type: "ADD_PERSON_TO_PARTY", payload: person}) | |
const removePersonFromParty = (person) => ({type: "REMOVE_PERSON_FROM_PARTY", payload: person}) | |
const reducer = (state = store, action) => { | |
switch (action.type) { | |
case "ADD_PERSON_TO_PARTY": |