- SPA_ARTICLE_CODE.zip
- SPA_ARTICLE_CODE
- ChainOfPluginsCompositionSample
- ComplexProductNavigationTest
- CompositionAndNavigationSample
- HierarchicalSPAWithNavigation
- ParameterizedPluginSample
- ParamNavigationTest
- SilverlightPluginSample
- SimpleCompositionSample
- SimpleProductNavigationTest
- SPA_POSTingObjectToServer
- SPAComplexObjectGetter
- SPAServerStringCommunications
- TwoPageOrdinaryHTMLApp
- TwoPageSPA
- TwoPageSPAWithNavigation
- TwoPageSPAWithTabs
- BPF.zip
- BPF
|
// BPF JavaScript library version 0.9
// (c) Nick Polyak 2012 - http://awebpros.com/
// License: Code Project Open License (CPOL) 1.92(http://www.codeproject.com/info/cpol10.aspx)
//
// short overview of copyright rules:
// 1. you can use this framework in any commercial or non-commercial
// product as long as you retain this copyright message
// 2. Do not blame the author(s) of this software if something goes wrong.
//
// Also as a courtesy, please, mention this software in any documentation for the
// products that use it.
/// <reference path="SimpleEvent.js" />
// should fire only if all events completed.
// if one or more events failed returns false, iff all events succeeded returns true
"use strict";
var bpf = bpf || {};
bpf.utils = bpf.utils || {};
bpf.utils.EventBarrier = function () {
var eventToFireAtTheEnd = new SimpleEvent();
var events = {};
var eventId = 0;
var resultSuccess = true;
var numberEvents = 0;
this.getNumberEvents = function() {
return numberEvents;
}
this.addSimpleEventHandler = function (eventHandler) {
eventToFireAtTheEnd.addSimpleEventHandler(eventHandler);
};
this.addCallback = function (event, eventName) {
var self = this;
eventId++;
var eventData = {
id: eventId,
event: event
};
if (eventName)
eventData.name = eventName;
events[eventId] = eventData;
numberEvents++;
event.addSimpleEventHandler(function (success) {
delete events[eventId];
numberEvents--;
resultSuccess = resultSuccess && success;
if (numberEvents === 0)
eventToFireAtTheEnd.fire(self, resultSuccess);
});
}
this.createChildEventBarrier = function(childEventBarrierName) {
var childEventBarrier = new bpf.utils.EventBarrier();
var childEventBarrierFiredEvent = new SimpleEvent();
this.addCallback(childEventBarrierFiredEvent, childEventBarrierName);
// when the child event product is done, the simple event
// which is one of the callbacks for the parent. This will reduce the
// parent's reference count and if the parent's reference count is zero,
// fire the event-at-the-end.
childEventBarrier.addSimpleEventHandler(function (success) {
childEventBarrierFiredEvent.fire();
});
return childEventBarrier;
}
};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a software architect and a developer with great passion for new engineering solutions and finding and applying design patterns.
I am passionate about learning new ways of building software and sharing my knowledge with others.
I worked with many various languages including C#, Java and C++.
I fell in love with WPF (and later Silverlight) at first sight. After Microsoft killed Silverlight, I was distraught until I found Avalonia - a great multiplatform package for building UI on Windows, Linux, Mac as well as within browsers (using WASM) and for mobile platforms.
I have my Ph.D. from RPI.
here is my linkedin profile