Logo
TGCATALOG
Catalog Collections Blog
Kotlin | Interview Questions

Kotlin | Interview Questions

Interview questions for Kotlin developers with answers.

No ratings
726
29.10.2026
726
29.10.2026
No ratings
726
29.10.2026
Safe redirect via bot
О канале

Interview questions for Kotlin developers with answers.

Подписчиков 2,451
Тематика Technology
Язык English
Ссылка t.me/easy_kotlin

We also recommend

Kekaton AI | Voiceover and voice clone
Kekaton AI | Voiceover and voice clone
Bot

AI bot for text-to-speech and voice cloning in Telegram. Create audio using neural network quickly and easily.

Description

Kotlin interview questions: extensions, coroutines, collections. With code examples and explanations for Android and backend.

Latest posts

Kotlin | Interview Questions
Kotlin | Interview Questions
🔒Открыть пост
и посмотреть медиа
🤔 Как с MVI обрабатывать события, которые не нужно хранить? В MVI (Model-View-Intent) есть проблема: события, которые не нужно хранить в State, могут повторно отобразиться при пересоздании экрана (например, при повороте экрана или навигации назад). Показ Toast / Snackbar Навигация (openScreen()) Ошибки, которые нужно показать один раз 🟠Используем `SingleLiveEvent` (для ViewModel) Это LiveData, которая отправляет событие только один раз и не пересылает его новым подписчикам. class SingleLiveEvent : MutableLiveData() { private val pending = AtomicBoolean(false) override fun observe(owner: LifecycleOwner, observer: Observer) { super.observe(owner) { value -> if (pending.compareAndSet(true, false)) { observer.onChanged(value) } } } override fun setValue(value: T?) { pending.set(true) super.setValue(value) } } ViewModel с SingleLiveEvent class MyViewModel : ViewModel() { val eventShowToast = SingleLiveEvent() fun onButtonClicked() { eventShowToast.value = "Привет, это Toast!" } } Activity/Fragment подписывается viewModel.eventShowToast.observe(viewLifecycleOwner) { message -> Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show() } 🟠Используем `SharedFlow` (современный подход) В StateFlow все события хранятся в State (что не подходит для одноразовых событий). Вместо этого используем SharedFlow с replay = 0, чтобы событие не повторялось. ViewModel с SharedFlow class MyViewModel : ViewModel() { private val _events = MutableSharedFlow() val events = _events.asSharedFlow() fun onButtonClicked() { viewModelScope.launch { _events.emit(UiEvent.ShowToast("Привет, это Toast!")) } } } sealed class UiEvent { data class ShowToast(val message: String) : UiEvent() object NavigateToNextScreen : UiEvent() } Подписка в UI: lifecycleScope.launchWhenStarted { viewModel.events.collect { event -> when (event) { is UiEvent.ShowToast -> Toast.makeText(context, event.message, Toast.LENGTH_SHORT).show() is UiEvent.NavigateToNextScreen -> findNavController().navigate(R.id.nextFragment) } } } 🟠Используем `EventWrapper` (обходной путь для StateFlow) Если в State всё-таки нужно хранить событие, но не показывать его повторно, можно использовать EventWrapper. class EventWrapper(private val content: T) { private var hasBeenHandled = false fun getContentIfNotHandled(): T? { return if (hasBeenHandled) null else { hasBeenHandled = true content } } } ViewModel с StateFlow: data class UiState(val message: EventWrapper? = null) class MyViewModel : ViewModel() { private val _state = MutableStateFlow(UiState()) val state = _state.asStateFlow() fun onButtonClicked() { _state.value = UiState(message = EventWrapper("Привет, это Toast!")) } } UI подписывается и проверяет EventWrapper: viewModel.state.collect { state -> state.message?.getContentIfNotHandled()?.let { message -> Toast.makeText(context, message, Toast.LENGTH_SHORT).show() } } Ставь 👍 и забирай 📚 Базу знаний
Kotlin | Interview Questions
FAQ

Open Kotlin | Interview Questions in Telegram and press the Start button. No separate registration is required.

Yes. The service is designed to be straightforward: open the resource, follow the on-screen instructions and start using it.

No. You can use Kotlin | Interview Questions directly in Telegram unless the resource description says otherwise.

Access depends on the resource. Check the current information in Telegram after opening Kotlin | Interview Questions.

The exact features depend on the resource. Open Kotlin | Interview Questions to see its current functions, content and access conditions.
Subscriber dynamics
+0.0% last 30 days
Current
2,451
Month ago
2,450
Average growth
+0 / day
Updated
15 hours ago

Reviews for channel Kotlin | Interview Questions

Log in to leave a review

Only registered users can share their opinion.

No reviews yet

Be the first to share your impression of this resource!

Similar resources

Loading
Switch to Light Theme
Home Catalog Collections Blog Login