Skip to content

Instantly share code, notes, and snippets.

@trinhcu18
trinhcu18 / nodejs-custom-es6-errors.md
Created July 10, 2018 07:35 — forked from slavafomin/nodejs-custom-es6-errors.md
Custom ES6 errors in Node.js

Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.

I've tried to make it as lean and unobtrusive as possible.

Defining our own base class for errors

errors/AppError.js

@trinhcu18
trinhcu18 / FragmentObserver.java
Created August 29, 2018 08:19 — forked from alexfu/FragmentObserver.java
Observer pattern for notifying Fragments of a ViewPager to update their views. This will update the current Fragment, as well as the off screen Fragments that are retained.
public class FragmentObserver extends Observable {
@Override
public void notifyObservers() {
setChanged(); // Set the changed flag to true, otherwise observers won't be notified.
super.notifyObservers();
}
}