From b61deee5927ebc300a241736585563ec81142003 Mon Sep 17 00:00:00 2001 From: dskvr Date: Tue, 17 Sep 2024 03:52:31 +0200 Subject: [PATCH] improve README --- README.md | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7e9aabb..cdac9a9 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,8 @@ Updates to notemine can be accessed via observables. ``` notemine.progress$ notemine.error$ -notemine.progress$ -notemine.progress$ +notemine.cancelled$ +notemine.success$ ``` @@ -82,24 +82,35 @@ notemine.progress$ const numberOfMiners = 8 let miner: NostrMiner; let progress: Writable = new writable(new Array(numberOfMiners)) + let success: Writeable = new writable(null) onMount(() => { miner = new NostrMiner({ content: 'Hello, Nostr!', numberOfMiners }); - const subscription = miner.progress$.subscribe(progress_ => { + const progress$ = miner.progress$.subscribe(progress_ => { progress.update( _progress => { _progress[progress_.workerId] = progress_ + return _progress + }) + }); + + const success$ = miner.progress$.subscribe(success_ => { + const {event, totalTime, hashRate} + success.update( _success => { + _success = success_ + return _success }) + miner.cancel(); }); miner.mine(); return () => { - subscription.unsubscribe(); + progress$.unsubscribe(); + success$.unsubscribe(); miner.cancel(); }; }); - $: miners = $progress @@ -109,6 +120,12 @@ notemine.progress$ Miner #{miner.workerId}: {miner.hashRate}kH/s [Best PoW: ${miner.bestPowData}] {/each} +{#if($success !== null)} +
+  {$success.event}
+  
+{/if} + ```