Effection Logo

function useAttributes

thefrontside/effection

function* useAttributes(attrs: Partial<Attributes>): Operation<void>

Add metadata to the current Scope that can be used for display and debugging purposes.

Calling useAttributes() multiple times will add new attributes and overwrite attributes of the same name, but it will not erase old ones.

Examples

Example 1

function useServer(port: number): Operation<Server> {
  return resource(function*(provide) {
    yield* useAttributes({ name: "Server", port });
    let server = createServer();
    server.listen();
    try {
      yield* provide(server);
    } finally {
      server.close();
    }
  });
}

Parameters

attrs: Partial<Attributes>

  • attributes to add to this Scope

Return Type

Operation<void>

an Oeration adding attrs to the current scope