Skip to content

Instantly share code, notes, and snippets.

@gajus
Last active March 12, 2018 14:44
Show Gist options
  • Save gajus/5d183b3cf7bf775a03e9 to your computer and use it in GitHub Desktop.
Save gajus/5d183b3cf7bf775a03e9 to your computer and use it in GitHub Desktop.
let doFoo = new WeakMap(),
doBar = new WeakMap();
class Foo {
constructor () {
doFoo.set(this, () => {
// definition of doFoo for the instance of Foo.
});
doBar.set(this, () => {
// definition of doBar for the instance of Foo.
});
}
publicMethodThatUsesFoo () {
doFoo.get(this)(); // call doFoo
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment