You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While JavaScript doesn't natively allow for this (everything's a runtime variable), you may be able to solve what you are trying to do with some sort of class registry:
// the below has not been tested// definitionvarClassRegistry;(function(){varAsStatic=Fiber.extend(function(){return{init: function(){this.classes=[];this.lookup={};},register: function(name,klass){this.classes.push(klass);this.lookup[this.classes.length-1]=name;},getInstance: function(klass){for(vari=0,len=this.classes.length;i<len;i++){if(klassinstanceofthis.classes[i]){returnthis.lookup[i];}}}};});ClassRegistry=newAsStatic();}());// usagevarMyClass=Fiber.extend(function(){// ...});ClassRegistry.register('MyClass',MyClass);varmyClass=newMyClass();ClassRegistry.getInstance(myClass);// MyClass
In many ways, this may be better as you'll have better control of your use case. Fiber specifically avoids these kinds of features in order to keep the implementation as close to a syntactic sugar layer for native code as possible.
Is there a way of finding what Fiber class a variable I have is an instance of?
The text was updated successfully, but these errors were encountered: