Last active
August 29, 2015 14:20
-
-
Save kriszyp/cdd6fa337eebb3d8ba55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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