code: function (incomingPromise, dataSource) {
                      var signal = new _Signal();
                      incomingPromise.then(
                          function (v) { signal.complete(v); },
                          function (e) { signal.error(e); }
                      );
                      var resultPromise = signal.promise.then(null, function (e) {
                          if (e.name === "WinJS.UI.VirtualizedDataSource.resetCount") {
                              getCountPromise = null;
                              return incomingPromise = dataSource.getCount();
                          }
                          return Promise.wrapError(e);
                      });
                      var count = 0;
                      var currentGetCountPromise = {
                          get: function () {
                              count++;
                              return new Promise(
                                  function (c, e) { resultPromise.then(c, e); },
                                  function () {
                                      if (--count === 0) {
                                          // when the count reaches zero cancel the incoming promise
                                          signal.promise.cancel();
                                          incomingPromise.cancel();
                                          if (currentGetCountPromise === getCountPromise) {
                                              getCountPromise = null;
                                          }
                                      }
                                  }
                              );
                          },
                          reset: function () {
                              signal.error(new _ErrorFromName("WinJS.UI.VirtualizedDataSource.resetCount"));
                          },
                          cancel: function () {
                              // if explicitly asked to cancel the incoming promise
                              signal.promise.cancel();
                              incomingPromise.cancel();
                              if (currentGetCountPromise === getCountPromise) {
                                  getCountPromise = null;
                              }
                          }
                      };
                      return currentGetCountPromise;
                  }
docs: Create a helper which issues new promises for the result of the input promise but have their cancelations ref-counted so that any given consumer canceling their promise doesn't result in the incoming promise being canceled unless all consumers are no longer interested in the result.