Constructor
# new FabricContractRepositoryObservableHandler()
Emits events on the Fabric ledger when repository operations occur
Observer handler for Fabric chaincode events
sequenceDiagram
participant Repository
participant ObservableHandler
participant Stub
participant Ledger
Repository->>ObservableHandler: updateObservers(log, table, event, id, ctx)
ObservableHandler->>ObservableHandler: Check if event is supported
ObservableHandler->>ObservableHandler: generateFabricEventName(table, event, owner)
ObservableHandler->>Stub: setEvent(eventName, payload)
Stub->>Ledger: Record event
Example
```typescript
// In a Fabric chaincode contract
import { FabricContractRepositoryObservableHandler } from '@decaf-ts/for-fabric';
// Create a handler with default supported events
const handler = new FabricContractRepositoryObservableHandler();
// Emit an event
await handler.updateObservers(
logger,
'assets',
OperationKeys.CREATE,
'asset1',
context
);
```
Extends
- ObserverHandler
Classes
- FabricContractRepositoryObservableHandler
Initializes the handler with a list of supported events
- FabricContractRepositoryObservableHandler
Initializes the handler with a list of supported events
Methods
# async updateObservers(log, table, event, id, ctx, owneropt, owneropt) → {Promise.<void>}
Emits events on the Fabric ledger for supported event types
Updates observers by emitting Fabric events
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
log |
Logger
|
Logger instance for debugging |
|
table |
string
|
The table/collection name |
|
event |
OperationKeys
|
BulkCrudOperationKeys
|
string
|
The event type |
|
id |
EventIds
|
The event identifier |
|
ctx |
FabricContractContext
|
The Fabric contract context |
|
owner |
string
|
<optional> |
Optional owner identifier for the event |
owner |
object
|
string
|
undefined
|
<optional> |
Optional payload for the event |
Promise that resolves when the event is emitted
Promise.<void>