Skip to content

Instantly share code, notes, and snippets.

Sébastien Ollivier sebastieno

Block or report user

Report or block sebastieno

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View reusePendingObservable.decorator.ts
import { Observable } from 'rxjs';
import { finalize, share } from 'rxjs/operators';
export function ReusePendingObservable() {
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
const originalMethod = descriptor.value;
const pendingObservablePropertyName = `__pendingObservable${propertyKey}`;
target[pendingObservablePropertyName] = null;
descriptor.value = function (...args: any[]) {
@sebastieno
sebastieno / cacheable.ts
Last active May 25, 2018
Helper function which cache an observable result
View cacheable.ts
import { Observable, ReplaySubject } from 'rxjs';
export function cacheable<T>(observable: Observable<T>): Observable<T> {
const replaySubject = new ReplaySubject<T>(1);
observable.subscribe(x => replaySubject.next(x), x => replaySubject.error(x), () => replaySubject.complete());
return replaySubject.asObservable();
}
@sebastieno
sebastieno / httpRequestLocker.js
Created Mar 27, 2016
Http request locker for AngularJS
View httpRequestLocker.js
var IS;
(function (IS) {
var HttpRequestLocker = (function () {
function HttpRequestLocker($http, $q, requestConfig, successCallback) {
this.$http = $http;
this.$q = $q;
this.requestConfig = requestConfig;
this.successCallback = successCallback;
}
HttpRequestLocker.prototype.execute = function () {
You can’t perform that action at this time.