Add new snippet for api.query.balances.freeBalance.multi (#1288)

This commit is contained in:
Chevdor 2019-06-10 19:01:04 +02:00 committed by Jaco Greeff
parent 06a8870385
commit 2f0172a033
2 changed files with 20 additions and 1 deletions

View File

@ -15,7 +15,8 @@ import {
storageGetInfo,
storageSystemEvents,
storageListenToBalanceChange,
storageRetrieveInfoOnQueryKeys
storageListenToMultipleBalancesChange,
storageRetrieveInfoOnQueryKeys
} from './storage-examples';
import { extrinsicMakeTransfer } from './extrinsics-examples';
@ -28,6 +29,7 @@ const snippets: Array<Snippet> = [
storageGetInfo,
storageSystemEvents,
storageListenToBalanceChange,
storageListenToMultipleBalancesChange,
storageRetrieveInfoOnQueryKeys,
extrinsicMakeTransfer
];

View File

@ -85,6 +85,23 @@ api.query.balances.freeBalance(ALICE, (balance) => {
});`
};
export const storageListenToMultipleBalancesChange: Snippet = {
value: 'storageListenToMultipleBalancesChange',
text: 'Listen to multiple balances changes',
label: { color: 'blue', children: 'Storage', size: 'tiny' },
code: `// You may leave this example running and make a transfer
// of any value from or to Alice/Bob address in the 'Transfer' App
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
const BOB = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';
console.log('Tracking balances for:', [ALICE, BOB])
// Subscribe and listen to several balance changes
api.query.balances.freeBalance.multi([ALICE, BOB], (balance) => {
console.log('Change detected, new balances: ', balance)
});`
};
export const storageRetrieveInfoOnQueryKeys: Snippet = {
value: 'storageRetrieveInfoOnQueryKeys',
text: 'Retrieve Info on query keys',