Skip to content

Instantly share code, notes, and snippets.

@kriszyp
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kriszyp/cdd6fa337eebb3d8ba55 to your computer and use it in GitHub Desktop.
Save kriszyp/cdd6fa337eebb3d8ba55 to your computer and use it in GitHub Desktop.
import { mixin, declareFrom, after } from 'core/traits' or 'core/compose'
class Request {
get() { }
}
class Cache {
@after /* add something to the method so that mixin knows that it should run after the method it is overriding? */
get() {
}
invalidate() { }
}
@mixin(Cache) /* this could mixin the functionality from Cache, I think, but of course won't add type information from Cache */
class UserRequestMemory extends Request {
/* user can explicitly declare which methods they will actually need, (and even choose which mixin to take precedent),
for example with Cache, most of it is just about altering behavior of existing methods, but if we did need to access a Cache method: */
@declareFrom(Cache)
invalidate() { throw }
}
var store = new UserRequestMemory();
store.get();
store.invalidate();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment