11/*******************************************************************************
2- * Copyright (C) 2024 Diffusion Data Ltd.
2+ * Copyright (C) 2024 - 2025 Diffusion Data Ltd.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -22,6 +22,8 @@ export async function subscribeSingleTopicExample() {
2222 /// tag::log
2323 const check = new PartiallyOrderedCheckpointTester ( [
2424 [ 'Subscribed to my/topic/path' ] ,
25+ [ 'my/topic/path changed from undefined to {"diffusion":"data"}' ] ,
26+ [ 'my/topic/path changed from {"diffusion":"data"} to {"diffusion":"more data"}' ] ,
2527 [ 'Closed' ] ,
2628 ] ) ;
2729 /// end::log
@@ -57,15 +59,31 @@ export async function subscribeSingleTopicExample() {
5759 } ,
5860 /// end::log
5961 value : ( topic , spec , newValue , oldValue ) => {
60- console . log ( `${ topic } changed from ${ oldValue . get ( ) } to ${ newValue . get ( ) } ` ) ;
62+ console . log ( `${ topic } changed from ${ JSON . stringify ( oldValue ? .get ( ) ) } to ${ JSON . stringify ( newValue ? .get ( ) ) } ` ) ;
6163 /// tag::log
62- check . log ( `${ topic } changed from ${ oldValue . get ( ) } to ${ newValue . get ( ) } ` ) ;
64+ check . log ( `${ topic } changed from ${ JSON . stringify ( oldValue ? .get ( ) ) } to ${ JSON . stringify ( newValue ? .get ( ) ) } ` ) ;
6365 /// end::log
6466 }
6567 } ) ;
6668
6769 await session . select ( 'my/topic/path' ) ;
6870
71+ await session . topicUpdate . set (
72+ 'my/topic/path' ,
73+ diffusion . datatypes . json ( ) ,
74+ diffusion . datatypes . json ( ) . from ( { "diffusion" : "data" } )
75+ ) ;
76+
77+ await new Promise ( resolve => setTimeout ( resolve , 2000 ) ) ;
78+
79+ await session . topicUpdate . set (
80+ 'my/topic/path' ,
81+ diffusion . datatypes . json ( ) ,
82+ diffusion . datatypes . json ( ) . from ( { "diffusion" : "more data" } )
83+ ) ;
84+
85+ await new Promise ( resolve => setTimeout ( resolve , 2000 ) ) ;
86+
6987 await session . closeSession ( ) ;
7088 /// end::pub_sub_subscribe_single_topic_via_path[]
7189 /// tag::log
0 commit comments