How to use the co.withSharedContext function in co

To help you get started, we’ve selected a few co examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hipages / inceptum / test / transaction / TransactionManager.js View on Github external
* setVal(key, val) {
    return co.withSharedContext((context) => {
      context[key] = val;
    });
  }
  * getVal(key) {
github hipages / inceptum / test / transaction / TransactionManager.js View on Github external
* registerRollbackListenerAndThrow(listener) {
    return co.withSharedContext((context) => {
      context.currentTransaction.addRollbackListener(listener);
      throw new Error('Exception thrown');
    });
  }
}
github hipages / inceptum / test / transaction / TransactionManager.js View on Github external
* runMethod1InReadWrite() {
    return co.withSharedContext((context) => {
      demand(context).is.not.undefined();
      demand(context.currentTransaction).is.not.undefined();
      context.currentTransaction.isReadonly().must.be.false();
    });
  }
  * setVal(key, val) {
github hipages / inceptum / test / transaction / TransactionManager.js View on Github external
* runMethod1InReadonly() {
    return co.withSharedContext((context) => {
      demand(context).is.not.undefined();
      demand(context.currentTransaction).is.not.undefined();
      context.currentTransaction.isReadonly().must.be.true();
    });
  }
  * runMethod1InReadWrite() {
github hipages / inceptum / test / transaction / TransactionManager.js View on Github external
* getVal(key) {
    return co.withSharedContext(
      (context) =>
        context[key]
    );
  }
  * getTransaction() {
github hipages / inceptum / test / transaction / TransactionManager.js View on Github external
* saveTransactionAndThrow() {
    return co.withSharedContext((context) => {
      context.savedTransaction = context.currentTransaction;
      throw new Error('Exception thrown');
    });
  }
  * registerCommitListener(listener) {
github hipages / inceptum / test / transaction / TransactionManager.js View on Github external
* checkTransactionReused() {
    return co.withSharedContext(function* (context) {
      context.marker1 = 'the value of marker1';
      yield TransactionManager.runInTransaction(true, Util.prototype.validateMarker1, this);
    });
  }
  * delegateToReadWriteTransaction() {
github hipages / inceptum / test / transaction / TransactionManager.js View on Github external
* validateMarker1() {
    return co.withSharedContext((context) => {
      demand(context.marker1).be.not.undefined();
      context.marker1.must.be.equal('the value of marker1');
    });
  }
  * checkTransactionStarted() {
github hipages / inceptum / test / transaction / TransactionManager.js View on Github external
* mustBeInTransaction() {
    return co.withSharedContext((context) => {
      demand(context).is.not.undefined();
      demand(context.currentTransaction).is.not.undefined();
    });
  }
  * runMethod1InReadonly() {
github hipages / inceptum / test / transaction / TransactionManager.js View on Github external
* markTransaction() {
    return co.withSharedContext((context) => {
      context.currentTransaction.myMark = 1;
    });
  }
  * validateNoMarkInTransaction() {