```java // Listen for sign out events. final String signedOutEventName = AuthChannelEventName.SIGNED_OUT.toString(); Amplify.Hub.subscribe(HubChannel.AUTH, anyAuthEvent -> signedOutEventName.equals(anyAuthEvent.getName()), // When one arrives, clear the DataStore. signedOutEvent -> Amplify.DataStore.clear( () -> Log.i("MyAmplifyApp", "DataStore is cleared."), failure -> Log.e("MyAmplifyApp", "Failed to clear DataStore.") ) ); ``` ```kotlin Amplify.Hub.subscribe(HubChannel.AUTH, { // Listen for sign out events. it.name.equals(AuthChannelEventName.SIGNED_OUT.toString()) }, { // When one arrives, clear the DataStore. Amplify.DataStore.clear( { Log.i("MyAmplifyApp", "DataStore is cleared") }, { Log.e("MyAmplifyApp", "Failed to clear DataStore") } ) } ) ``` ```kotlin Amplify.Hub.subscribe(HubChannel.AUTH) { it.name == AuthChannelEventName.SIGNED_OUT.toString() } // When sign out event arrives, clear the DataStore. .onEach { Amplify.DataStore.clear() } .catch { Log.e("MyAmplifyApp", "Failed to clear DataStore.", it) } .collect { Log.i("MyAmplifyApp", "DataStore is cleared.") } ``` ```java // Listen for sign out events. final String signedOutEventName = AuthChannelEventName.SIGNED_OUT.toString(); RxAmplify.Hub.on(HubChannel.AUTH) .filter(event -> signedOutEventName.equals(event.getName())) .flatMapObservable(RxAmplify.DataStore::clear) .subscribe( () -> Log.i("MyAmplifyApp", "DataStore is cleared."), failure -> Log.e("MyAmplifyApp", "Failed to clear DataStore.") ); ```