From 3699f000420278f403dbdc2b8225b7081ebd898d Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Sat, 19 Sep 2015 14:14:55 -0700 Subject: [PATCH] Reorder adding the listener Fixes #3 --- .../com/github/reiseburo/rx/curator/PathChildren.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/reiseburo/rx/curator/PathChildren.java b/src/main/java/com/github/reiseburo/rx/curator/PathChildren.java index 222eb78..b43a824 100644 --- a/src/main/java/com/github/reiseburo/rx/curator/PathChildren.java +++ b/src/main/java/com/github/reiseburo/rx/curator/PathChildren.java @@ -50,11 +50,6 @@ public class PathChildren { @Override public void call(final Subscriber subscriber) { cache = new PathChildrenCache(curatorFramework, znodePath, true); - try { - cache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT); - } catch (Exception ex) { - subscriber.onError(ex); - } cache.getListenable().addListener(new PathChildrenCacheListener() { @Override @@ -62,6 +57,12 @@ public class PathChildren { subscriber.onNext(event); } }); + + try { + cache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT); + } catch (Exception ex) { + subscriber.onError(ex); + } } }).doOnUnsubscribe(new Action0() { @Override