Skip to content

Instantly share code, notes, and snippets.

View klemensz's full-sized avatar

Klemens Zleptnig klemensz

View GitHub Profile
@klemensz
klemensz / SomeViewModel.kt
Last active March 17, 2022 18:22
Fetch data with an observed location and a timeout
class SomeViewModel(private val locationRepository: LocationRepository) : ViewModel() {
// ...
private suspend fun fetchFromRemote() {
// Initialize some variables:
var gotObservedLocation = false // Did we get an observed location?
var isTimeout = false // Will be set to true once the timeout is reached
var timeoutMs = 500L // Timeout in ms
@klemensz
klemensz / hide-header.directive.ts
Last active September 30, 2023 20:35
Hide header on scroll in Ionic 5
import { Directive, HostListener, Input, OnInit, Renderer2 } from '@angular/core';
import { DomController } from '@ionic/angular';
/**
* Moves away the header when scrolling down.
*/
@Directive({
selector: '[appHideHeader]',
})
export class HideHeaderDirective implements OnInit {