Event handling

This section covers event subscriptions for tracking action progress and state changes.


Overview

Actions emit events throughout their lifecycle. These events can be used to update application UI and track progress.


Event Types

Event
Payload
Description

status-change

string

Status changed

progress

StrategyProgress

Detailed progress update

completed

void

Operation completed successfully

failed

void

Operation failed

error

LombardError

Error occurred


Subscribing to Events

import { createLombardSDK, Chain, AssetId, StakeEvent } from '@lombard.finance/sdk';
import { config } from './lib/lombard';

const sdk = createLombardSDK(config);

const stake = sdk.chain.btc.stake({
  destChain: Chain.ETHEREUM,
  assetOut: AssetId.LBTC,
});

stake.on(StakeEvent.StatusChange, (status) => {
  // status: 'idle' | 'needs_fee_authorization' | 'ready' | 'address_ready'
});

stake.on(StakeEvent.Progress, (progress) => {
  // progress.status, progress.steps, progress.confirmations
});

stake.on(StakeEvent.Completed, () => {
  // Operation completed
});

stake.on(StakeEvent.Error, (error) => {
  // error.code, error.message, error.metadata
});

Progress Object


Unsubscribing


Event Constants

Each action type has its own event constants.

All event types have the same shape:


Last updated