Skip to content

Instantly share code, notes, and snippets.

View ValeriusGC's full-sized avatar

Valery Kulikov ValeriusGC

  • Russia, Yekaterinburg
View GitHub Profile
@ValeriusGC
ValeriusGC / get_rx_decorator.dart
Last active May 9, 2022 10:56
GetRxDecorator - UDF for Getx variables
import 'package:equatable/equatable.dart';
import 'package:get/get_rx/get_rx.dart';
/// GetRxDecorator for Rx<T> variables in Get library [https://pub.dev/packages/get]
/// This wrapper lets to apply UDF concept and makes it easier
/// to work with Getx' Rx<T> and Obx.
///
/// ============================================================================
///
/// Why one need to use this decorator? Because of problem with Rx<T> variables:
@ValeriusGC
ValeriusGC / statex_widget.dart
Created August 7, 2021 02:44
Manages GetxControllers everywhere
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
/// [StatexWidget] helps to manage [GetxController]s lifecycle
/// according its [Widget]s in cases when [Getx] doesn't.
///
/// Examples:
/// 1. PageView.childs[Widget1(), Widget2(), ...]
/// 2. Get.bottomSheet(Widget())
///
@ValeriusGC
ValeriusGC / statex_widget.dart
Last active May 2, 2022 17:51
Расширение возможностей инжектирования контроллеров для GetX
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'package:rxdart/rxdart.dart' as rx;
/// Автоинжектор для связки времени жизни одного контроллера с одним виджетом
///
/// Является заменителем `...binding: BindingsBuilder.put(() => T())`
/// или `Get.put(()=>T())`
/// в случаях, когда требуется автоматически привязать время жизни контроллера
/// к имплементациям виджетов, не участвующих в GetPageRoutes
@ValeriusGC
ValeriusGC / SmartViewConcept.kt
Created April 20, 2018 05:21
Extends [ViewModel] with several handy classes and properties
package com.gdetotut.sample.smartprop
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.subjects.PublishSubject
import javafx.beans.binding.BooleanBinding
import javafx.beans.property.Property
import tornadofx.*
/**
* `Smart`-conception extends [ViewModel] with handy properties like
@ValeriusGC
ValeriusGC / RxFromAction.java
Created March 16, 2018 10:32
RxJava2. How make Observable from VoidMethod. And how test Rx-Exceptions with JUnit.
import io.reactivex.Completable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import io.reactivex.observers.DisposableCompletableObserver;
import io.reactivex.observers.TestObserver;
import org.junit.Test;
import java.util.Observable;
public class RxFromAction {
@ValeriusGC
ValeriusGC / WithRx2.java
Created March 16, 2018 07:33
Sample on RxJava2. Illustrates how to connect complex processes that call each other and to traverse event messages through.
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.observers.DisposableObserver;
import io.reactivex.schedulers.Schedulers;
/**
* Замена вызовов лапши из колбеков на RxJava.
* <p>Задача - последовательное выполнение процессов.
@ValeriusGC
ValeriusGC / VfxSetUserTest.kt
Created March 5, 2018 04:53
Kotlin: This is how one can use parameterized tests along with Mockito-kotlin to provide cyclic tests of Event Handlers
package com.gdetotut.login
import com.nhaarman.mockito_kotlin.argumentCaptor
import com.nhaarman.mockito_kotlin.eq
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import java.util.Arrays
@ValeriusGC
ValeriusGC / VfxSetUserTest.java
Last active March 5, 2018 04:43
This is how one can use parameterized tests along with Mockito to provide cyclic tests of Event Handlers
package com.gdetotut.login;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.mockito.ArgumentCaptor;
import java.util.Arrays;
import java.util.Collection;
@ValeriusGC
ValeriusGC / EventHandlerTest.kt
Last active March 5, 2018 03:29
Kotlin: This show how to test Event Handlers with JUnit & 'Mockito-kotlin'
package vfx.kotlin
import com.nhaarman.mockito_kotlin.argumentCaptor
import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.verify
import org.junit.Assert
import org.junit.Test
data class Pizza(val name: String)
@ValeriusGC
ValeriusGC / EventHandlerTest.java
Last active March 4, 2018 14:18
This show how to test Event Handlers with JUnit & Mockito.
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
class PizzaJava {
private final String name;