tart-revocable

Tart implementation of a revocable reference

tart-revocable

Stability: 1 - Experimental

Implementation of a revocable proxy for Tiny Actor Run-Time in JavaScript.

@dalnefre, @tristanls

An implementation of a revocable proxy.

To run the below example run:

npm run readme
"use strict";
 
var revocable = require('../index.js'),
    tart = require('tart');
 
var sponsor = tart.minimal();
 
var actorBeh = function actorBeh(message) {
    console.log(message);
};
 
var actor = sponsor(actorBeh);
 
var capabilities = revocable.proxy(actor);
 
var proxy = sponsor(capabilities.proxyBeh);
proxy('hello');
proxy('revocable');
proxy('world');
 
var revoke = sponsor(capabilities.revokeBeh);
var ackCustomer = sponsor(function ackCustomerBeh() {
    console.log('revoke acked');
    proxy('this');
    proxy('does not get through');
});
revoke(ackCustomer);
npm test

Public API

  • actor: Actor function (message) {} Actor to create a revocable proxies for.
  • Return: Object An object containing behaviors for revocable proxies and a revoke capabilities for the proxies.
    • proxyBeh: Actor function (message) {} Actor behavior that will forward all messages to the actor it is a proxy for.
    • revokeBeh: Actor function (customer) {} Actor behavior that upon receipt of a message will revoke all proxies for the actor.
      • customer: Actor function () {} An ack will be sent to the customer upon revocation.