Skip to content

Commit

Permalink
Fix merge behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
lempiji committed Jun 14, 2020
1 parent d997dc9 commit a04e02e
Show file tree
Hide file tree
Showing 3 changed files with 395 additions and 25 deletions.
28 changes: 19 additions & 9 deletions examples/rx-fswatch/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,25 @@ void main()
auto shutdown = false;

auto thread = new Thread({
auto watch = FileWatch("./data", true);

while (!shutdown)
try
{
auto events = watch.getEvents();
if (events.length > 0)
auto watch = FileWatch("./data", true);

while (!shutdown)
{
.put(observer, events);
}
auto events = watch.getEvents();
if (events.length > 0)
{
.put(observer, events);
}

Thread.sleep(100.msecs);
Thread.sleep(100.msecs);
}
observer.completed();
}
catch (Exception e)
{
observer.failure(e);
}
});
thread.start();
Expand All @@ -30,7 +38,9 @@ void main()
});

auto flatten = watcher.map!(events => from(events)).merge();
auto changes = flatten.groupBy!(event => event.path).map!(o => o.debounce(2.seconds)).merge();
auto changes = flatten.groupBy!(event => event.path)
.map!(o => o.debounce(2.seconds))
.merge();

// start FileWatch
auto disposable = changes.doSubscribe((FileChangeEvent event) {
Expand Down
Loading

0 comments on commit a04e02e

Please sign in to comment.