Skip to content

Instantly share code, notes, and snippets.

View Vivekban's full-sized avatar

Vivek Bansal Vivekban

  • Crinoid Technologies Pvt. Ltd
  • Mississauga Ontario
View GitHub Profile
@Vivekban
Vivekban / FlowCombining.kt
Created March 18, 2024 13:28
Combing state and shared flow
suspend fun flowCombineFix() {
val sharedFlow = MutableSharedFlow<String>()
val stateFlow = MutableStateFlow<Int>(0)
combine(
// Emit default value on start
sharedFlow.onStart { emit("") },
stateFlow
) { shared, state ->
"$shared $state"
@Vivekban
Vivekban / ApiClient.kt
Last active January 20, 2024 00:47
Retrofit CallAdapter to handle the API calls errors and success states at single source.
package com.vivek.githubapisample.api
import com.vivek.githubapisample.BuildConfig
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
/**
* This class will be responsible to provide all kind Retrofit Client for making networking calls.
@Vivekban
Vivekban / UiString.kt
Last active December 27, 2023 23:57
UiString
import androidx.annotation.StringRes
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.res.stringResource
import com.crinoid.humotron.R
import com.crinoid.humotron.data.common.AppException
import retrofit2.HttpException
import java.io.IOException
import kotlin.String
@Vivekban
Vivekban / app_preference_util.dart
Created April 24, 2020 19:08
Flutter Shared Preference Utility file
import 'package:shared_preferences/shared_preferences.dart';
/// Singleton helper class for storing and fetching persistent data
/// in KEY-VALUE pair. Read data in synchronous way
///
/// For best practices, here we define all unique keys in integer
/// and handle default values
///
/// Note: this utils require plugin to work
/// In 'pubspec.ymal' add this line in dependencies
@Vivekban
Vivekban / README-Template.md
Created February 18, 2019 12:48 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites