-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Interfaces as string literals #2902
Comments
Are we basically talking about C#'s |
Hadn't used it before but seems right. |
Is this a dupe of #394 then? |
@danquirk, seems like this is different. |
@danquirk, seems to me that the initial suggestion on #394 is quite different. This |
I fully agree with @park9140. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/observe // A user model
var user = {
id: 0,
name: 'Brendan Eich',
title: 'Mr.'
};
// Create a greeting for the user
function updateGreeting() {
user.greeting = 'Hello, ' + user.title + ' ' + user.name + '!';
}
updateGreeting();
Object.observe(user, function(changes) {
changes.forEach(function(change) {
// Any time name or title change, update the greeting
if (change.name === nameof(user.name) || change.name === nameof(user.title)) {
updateGreeting();
}
});
}); |
looks like another duplicate of #3628 |
I have been looking at dependency injection and a few issues with refactoring in regards to
_.pluck
. One of the primary things I run into is that I want these things to enforce the interface for refactoring.A few examples
Interface used as a symbol for dependency injection
would compile to
In the case of an interface like pluck we could do something like this
would compile to
In this way we could enforce some level of type safety in common javascript reflection use cases.
The text was updated successfully, but these errors were encountered: