As mentioned in the interface section of 'Programming javascript applications' you can implement interfaces with stampit. When reducing the unnecessary stuff from the example, I end up with something like this:
const fooBarInterface =
stampit()
.methods(
{
foo: () => {
throw new Error('connect not implemented');
},
bar: () => {
throw new Error('save not implemented');
}
}
)
Excerpt from an interface definition:
If your class claims to implement an interface, all methods defined by that interface must appear in its source code before the class will successfully compile.
So now putting the interface in use
const fooBarImplementation =
stampit()
.compose(fooBarInterface)
.methods(
{
foo: () => {
// implement me
}
}
}
)
Now, when composing an object from the stamp, there should be an error because bar is not implemented by fooBarImplementation. It isn't, and I fear that it's pretty hard to get something like this in place because there is no compiling at all.
So, my question is: Am I doing it wrong or is this half baked thing what Eric Elliott calls an 'Interface'?
I'm debugging someone's code and wondering what this regex does? Code: <script> var t = document.getElementById("filterVal").value; var s = filterVal.replace(/"([^"]+(?="))"/g, '$1') </...
I'm debugging someone's code and wondering what this regex does? Code: <script> var t = document.getElementById("filterVal").value; var s = filterVal.replace(/"([^"]+(?="))"/g, '$1') </...
How do I use a dependency injected field in another field within the ember controller in 2.x Ember? For instance, I have export default Ember.Controller.extend({ session: Ember.inject.service(...
How do I use a dependency injected field in another field within the ember controller in 2.x Ember? For instance, I have export default Ember.Controller.extend({ session: Ember.inject.service(...
trying to use document.getElementById() in jsreport using the scripts section on the left menu, but it reports back Error occured - Error during rendering report: document is not defined What ...
trying to use document.getElementById() in jsreport using the scripts section on the left menu, but it reports back Error occured - Error during rendering report: document is not defined What ...
I did the following: Created a Google Form (e.g. form ID = ABC) Created a Google Sheet (let's call it sheet1) In sheet1's script editor, installed a trigger to my form with code such as the ...
I did the following: Created a Google Form (e.g. form ID = ABC) Created a Google Sheet (let's call it sheet1) In sheet1's script editor, installed a trigger to my form with code such as the ...