Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

List: race condition starting tests #58

Closed
wkeese opened this Issue · 4 comments

3 participants

@wkeese
Owner

See list-mark-1.html and probably some other samples and test files too:

<script type="text/javascript">
    require([
        "dojo/store/Memory",
        "dojo/store/Observable"
    ], function (MemoryStore, Observable) {
        globalStore = new Observable(MemoryStore({data: []}));
    });
</script>

<script type="text/javascript">
    var ready = false;
    require([
        "delite/register",
        "deliteful/list/List",
        "dojo/domReady!"
    ], function (register) {
        register.parse();
        ready = true;
    });
</script>
...
<d-list id="list-mark-1" style="height: 200px" selectionMode="multiple" store="globalStore" multiCharSearchDuration="5">

It's indeterminate which require()'s callback will execute first. It depends on how fast various modules load. If List completes loading before Memory and Observable, then it will evaluate the store="globalStore" before globalStore is defined.

I suggest again that you do it like this:

   <script>
       require(["dojo/store/Memory"], function (memory) {
           myStore = new MemoryStore({data: [...]});

         require(["delite/register", "deliteful/list/List"], function (register) {
            register.parse();
          }
       });
   </script>
   ...
   <d-list store="myStore"></d-list

Or an alternative would be to not set any store initially, but set it later:

    <script>
       require(["dojo/store/Memory", "delite/register", "deliteful/list/List"], function(memory, register) {
           register.parse();
           window.myList.store = new MemoryStore({data: [...]});
        });
   </script>
   ...
   <d-list id="myList"></d-list>

Note as usual that on Chrome the <d-list> widget will be instantiated as soon as List loads; it won't wait for the register.parse() call.

@sbrunot sbrunot was assigned by wkeese
@sbrunot
Collaborator

Thanks, I will use the first solution.

<script>
       require(["dojo/store/Memory"], function (memory) {
           myStore = new MemoryStore({data: [...]});

         require(["delite/register", "deliteful/list/List"], function (register) {
            register.parse();
          }
       });
   </script>
   ...
   <d-list store="myStore"></d-list>
@sbrunot
Collaborator

Fixed in commit cc000bc.

@sbrunot sbrunot closed this
@wkeese
Owner

As I mentioned above this error occurs in other files too. Namely ListGallery.html.

@wkeese wkeese reopened this
@sbrunot
Collaborator

Thanks, I've removed this html file in commit 4176b60.

@sbrunot sbrunot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.