Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is my attempt... What I don't really "get" about my attempt is whether it's 100% safe or not.</p> <p>If <code>store.add()</code> is called twice in a row, is is ever possible that <code>inMethod</code> is set to <code>true</code> by the first call, and that the second <code>add()</code> call then finds it already set to true because the first one hasn't managed to set it to false yet?</p> <p>This would only really be possible if <code>nextTick()</code> is called in between the two calls I assume?</p> <p>Or am I just completely confused by it all? (Which is very possible...)</p> <pre><code> topic.subscribe( 'hotplate/hotDojoStores/newStore', function( storeName, store ){ var inMethod; aspect.around( store, 'put', function( put ){ return function( object, options ){ if( inMethod ){ return when( put.call( store, object, options ) ); } else { inMethod = true; try { return when( put.call( store, object, options ) ).then( function( r ) { var eventName; var identity = store.idProperty; eventName = object[ identity ] ? 'storeRecordUpdate' : 'storeRecordCreate'; topic.publish( eventName, null, { type: eventName, storeName: storeName, objectId: r[ identity ], object: object }, false ); }); } finally { inMethod = false; } } } }); aspect.around( store, 'add', function( add ){ return function( object, options ){ if( inMethod ){ return when( add.call( store, object, options ) ); } else { inMethod = true; try { return when( add.call( store, object, options ) ).then( function( r ) { var identity = store.idProperty; topic.publish('storeRecordCreate', null, { type: 'storeRecordCreate', storeName: storeName, objectId: r[identity], object: object }, false ); }); } finally { inMethod = false; } } } }); aspect.around( store, 'remove', function( remove ){ return function( objectId, options ){ return when( remove.call( store, objectId, options ) ).then( function( r ) { topic.publish('storeRecordRemove', null, { type: 'storeRecordRemove', storeName: storeName, objectId: objectId }, false ); }); }; }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload