src/model.js
function (thisProperty, callbackArgs) {
                return function (callback) {

                    function notifyListener() {
                        if (Model.asyncEvents) {
                            setTimeout(function () {
                                callback.apply(thisProperty, callbackArgs);
                            }, 0);
                        } else {
                            callback.apply(thisProperty, callbackArgs);
                        }
                    }

                    if (Model.TRANSACTION_OPTIONS.flattenCallbacks || Model.TRANSACTION_OPTIONS.flattenCallbacksByHash) {
                        var callbackExecuted = false;
                        if (Model.TRANSACTION_OPTIONS.flattenCallbacks) {
                            if (executedCallbacks.indexOf(callback) === -1) { // Only call callback once
                                executedCallbacks.push(callback);
                                notifyListener();
                                callbackExecuted = true;
                            }
                        }
                        if (Model.TRANSACTION_OPTIONS.flattenCallbacksByHash) {
                            if (!callback.hash || callbackHashs.indexOf(callback.hash) === -1) { // Only call hash identified callback once
                                if (callback.hash) {
                                    callbackHashs.push(callback.hash);
                                }
                                if (!callbackExecuted) {
                                    notifyListener();
                                    callbackExecuted = true;
                                }
                            }
                        }
                    } else {
                        notifyListener();
                    }
                };
            }
function (thisProperty, callbackArgs) {
                return function (callback) {

                    function notifyListener() {
                        if (Model.asyncEvents) {
                            setTimeout(function () {
                                callback.apply(thisProperty, callbackArgs);
                            }, 0);
                        } else {
                            callback.apply(thisProperty, callbackArgs);
                        }
                    }

                    if (Model.TRANSACTION_OPTIONS.flattenCallbacks || Model.TRANSACTION_OPTIONS.flattenCallbacksByHash) {
                        var callbackExecuted = false;
                        if (Model.TRANSACTION_OPTIONS.flattenCallbacks) {
                            if (executedCallbacks.indexOf(callback) === -1) { // Only call callback once
                                executedCallbacks.push(callback);
                                notifyListener();
                                callbackExecuted = true;
                            }
                        }
                        if (Model.TRANSACTION_OPTIONS.flattenCallbacksByHash) {
                            if (!callback.hash || callbackHashs.indexOf(callback.hash) === -1) { // Only call hash identified callback once
                                if (callback.hash) {
                                    callbackHashs.push(callback.hash);
                                }
                                if (!callbackExecuted) {
                                    notifyListener();
                                    callbackExecuted = true;
                                }
                            }
                        }
                    } else {
                        notifyListener();
                    }
                };
            }
function ( thisProperty , callbackArgs ) { return function ( callback ) { function notifyListener ( ) { if ( Model . asyncEvents ) { setTimeout ( function ( ) { callback . apply ( thisProperty , callbackArgs ) ; } , 0 ) ; } else { callback . apply ( thisProperty , callbackArgs ) ; } } if ( Model . TRANSACTION_OPTIONS . flattenCallbacks || Model . TRANSACTION_OPTIONS . flattenCallbacksByHash ) { var callbackExecuted = false ; if ( Model . TRANSACTION_OPTIONS . flattenCallbacks ) { if ( executedCallbacks . indexOf ( callback ) === - 1 ) { // Only call callback once
 executedCallbacks . push ( callback ) ; notifyListener ( ) ; callbackExecuted = true ; } } if ( Model . TRANSACTION_OPTIONS . flattenCallbacksByHash ) { if ( ! callback . hash || callbackHashs . indexOf ( callback . hash ) === - 1 ) { // Only call hash identified callback once
 if ( callback . hash ) { callbackHashs . push ( callback . hash ) ; } if ( ! callbackExecuted ) { notifyListener ( ) ; callbackExecuted = true ; } } } } else { notifyListener ( ) ; } } ; }
This weird executeCallback function is a bit more complicated than it needs to be but is used to get around the JSLint warning of creating a function within the while loop below
This weird executeCallback function is a bit more complicated than it needs to be but is used to get around the JSLint warning of creating a function within the while loop below