Source Subkind not inheriting create method

edited January 2015 in Enyo 2.5
Creating a simple subkind of enyo.AjaxSource for some reason does not inherit the create method.
    name: 'MySource',
    kind: enyo.AjaxSource
Per the API documentation:
Creates an instance of enyo.Source with the given properties. These properties should include a kind property with the name of the kind of source and a name for the instance. This static method is also available on all subkinds of enyo.Source. The instance will automatically be added to the enyo.sources object and may be referenced by its name.
After some tinkering I discovered that it will inherit the method by forcing the private property noDefer to true like so:
    name: "MySource",
    kind: enyo.AjaxSource,
    urlRoot: "/api/",
    noDefer: true
This behavior however is not documented. Furthermore I don't understand why I have to force noDefer at all since it defaults to true in enyo.Source, gets set to true in enyo.XHRSource and again gets set to true in enyo.AjaxSource, though the API doesn't show it having a default value. Also none of the Developer Guides discuss this property when talking about making Source subkinds.

Why is the value for this property not inherited?
What is the actual reason for this property?


  • noDefer is there to defer the initialization of kinds until they are used in order to improve overall app startup time. In general, you don't have to worry about it but you've found a case in which you do. Congrats!

    enyo.Source attempts prevent you from needing to worry about it but it's failing. It tries to set noDefer in its concatHandler (more on that in Oop.js if you're curious) before then copying create() onto the new constructor but, unfortunately, that's not called until after a deferred constructor is finalized. In other words, "the goggles, they do nothing."

    The result is that once your custom Source has been created, it will have a create method but, of course, you're supposed to use create to create it in the first place. /sadtrombone

    So, adding noDefer: true is the solution as you've seen in XHRSource and AjaxSource.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!