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 re | |
# Define the file paths | |
sql_file_path = "" | |
kotlin_file_path = "" | |
# Read the SQLDelight file | |
with open(sql_file_path, 'r') as file: | |
sql_file_content = file.read() |
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
// Dagger | |
interface Authenticator | |
class RealAuthenticator @Inject constructor() : Authenticator | |
@Module | |
@ContributesTo(AppScope::class) | |
abstract class AuthenticatorModule { | |
@Binds abstract fun bindRealAuthenticator(authenticator: RealAuthenticator): Authenticator | |
} |
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
struct MoviesListScreenView: View { | |
@State var state: MoviesState = MoviesState(movies: [], selectedMovie: nil) | |
let viewModel = MoviesViewModel() | |
var body: some View { | |
List() { | |
ForEach(state.movies, id: \.self) { movie in | |
MovieView(movie, ...) | |
} | |
} |
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 MoviesFragment : Fragment() { | |
private val viewModel: MoviesViewModel by activityViewModels {...} | |
override fun onCreateView(inflater: LayoutInflater): View = ComposeView(inflater.context).apply { | |
layoutParams = ... | |
setContent { | |
val state by viewModel.observeState().collectAsState() | |
MoviesListView(state = state, onMovieSelected = { movie -> |
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 FlowWrapper<T>(private val source: Flow<T>) : Flow<T> by source { | |
init { | |
freeze() | |
} | |
fun collect(onEach: (T) -> Unit, onCompletion: (cause: Throwable?) -> Unit): Cancellable { | |
val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main) | |
scope.launch { | |
try { |
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 MoviesViewModel : | |
ArchViewModel<MoviesActions, MoviesState, MoviesEffects, MovieEvents, Nothing>( | |
updater = MoviesUpdater(), | |
initialState = MoviesState(), | |
initialEffects = setOf(MoviesEffects.LoadMovies()), | |
processor = MoviesProcessor(threadInfo), | |
) { | |
} |
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 MoviesProcessor() : Processor<MoviesEffects, MoviesActions> { | |
private val api : TMDApi = TMDApi() | |
override suspend fun dispatchSideEffect(effect: MoviesEffects): MoviesActions { | |
return when(effect){ | |
is MoviesEffects.LoadMovies -> getMovies(effect) | |
} | |
} |
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
typealias NextResult = Next<MoviesState, MoviesEffects, MovieEvents> | |
class MoviesUpdater : Updater<MoviesActions, MoviesState, MoviesEffects, MovieEvents> { | |
override fun onNewAction( | |
action: MoviesActions, | |
currentState: MoviesState | |
): Next<MoviesState, MoviesEffects, MovieEvents> { | |
return when (action) { | |
is MoviesActions.FetchMovies -> fetchMovies(action, currentState) | |
is MoviesActions.SaveMovies -> saveMovies(action, currentState) |
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 MoviesEffects( | |
override val dispatcher: CoroutineDispatcher = ..., | |
override val coroutineScope: CoroutineScope? = null) : SideEffectInterface { | |
object LoadMovies : MoviesEffects() | |
} |
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 MoviesActions { | |
object FetchMovies : MoviesActions() | |
data class SelectMovie(val movie: Movie) : MoviesActions() | |
data class SaveMovies(val movies: List<Movie>) : MoviesActions() | |
} |
NewerOlder