Skip to content

Instantly share code, notes, and snippets.

import { autoinject } from "aurelia-dependency-injection";
import { Router } from "aurelia-router";
import { ObserverLocator } from "aurelia-binding";
declare var $: any;
@autoinject()
export class ModalService {
constructor( private router: Router, private observerLocator: ObserverLocator ) {
this.observeRouterNavigation();
@Kukks
Kukks / window-close-notifier.ts
Created April 21, 2016 09:43
Wrapped the onbveforeload event is a static function to send a confirmation message when the user tries to close the window
export class WindowCloseNotifierHelper {
public static setMessage( message: any ) {
if ( message && _.isFunction(message) ) {
window.onbeforeunload = message;
} else if ( message ) {
window.onbeforeunload = ( e: any ) => {
if ( e ) {
e.returnValue = message;
}
@Kukks
Kukks / stringify.ts
Created April 15, 2016 11:02
Aurelia stringify value converter
export class StringifyValueConverter {
public toView( value: any ): string {
if ( value ) {
return JSON.stringify(value);
} else {
return "null object";
}
}
}
@Kukks
Kukks / unit-of-work-observer.ts
Last active February 14, 2020 09:03
Aurelia Unit Of Work Observer
import { CloneUtility } from "./clone";
import { Disposable } from "aurelia-binding";
import { BindingEngine } from "aurelia-binding";
/**
* Unit Of Work Observer
* Based on the work of fragsalat's MultiObserver found at
* https://gist.github.com/fragsalat/819a58021fc7b76a2704
*
*
* The purpose of this observer is to observe all changes made to a model and allows you