Adding listener when getting bucket through Supplier #184
-
I am trying to figure out how to add my listener when bucket is created first time. I am using below code `private Supplier getConfigSupplierForUser(String apiKey) {
Supplier configurationLazySupplier = getConfigSupplierForUser(apiKey);
` |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@haiderali22 Hello, // acquire cheap proxy to bucket
Bucket tokenBucket = buckets.getProxy(apiKey, configurationLazySupplier); The code above returns the bucket without listeners independently whether or not bucket had been created previously and listener were attached, because listeners are never stored in the GRID. Bucket persists only configuration and currently available tokens, so you can safely modify code like bellow, there is no chance that it will be multiple listeners on the same bucket // acquire cheap proxy to bucket
Bucket tokenBucket = buckets.getProxy(apiKey, configurationLazySupplier).toListenable(myListener); |
Beta Was this translation helpful? Give feedback.
@haiderali22 Hello,
The code above returns the bucket without listeners independently whether or not bucket had been created previously and listener were attached, because listeners are never stored in the GRID. Bucket persists only configuration and currently available tokens, so you can safely modify code like bellow, there is no chance that it will be multiple listeners on the same bucket