Giter VIP home page Giter VIP logo

beholder's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

beholder's Issues

Error killing the REPL when attempting to watch a file

The following error is found on Ubuntu 20

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Consider supporting fileTreeVisitor option in DirectorWatcher

Story

I have a scenario where I'm watching a directory for one specific file (to be added/changed/deleted). However this file is in a directory with many subdirectories and nested files. Calling beholder/watch on this dir takes about 1500 milliseconds on my machine. I did some experimentation by adding a custom visitor to the DirectorWatcher and I was able to bring this down to 5 milliseconds. Maybe this is interesting to add to beholder as an option.

Possible implementation

The DirectoryWatcher.Builder class allows to add a custom visitor option. This is currently not supported by beholder, but it could be added quite simple (see below). However the create would have to be made public or it would have to be forwarded via one of the watch functions, so API design is the hardest part here.

Below would be a possible implementation. Here is also a gist of how to create a visitor that can be used here.

(defn create
  "Creates a watcher taking a callback function `cb` that will be invoked
  whenever a file in one of the `paths` chages.

  Not meant to be called directly but use `watch` or `watch-blocking` instead."
  [cb paths & {:keys [^FileTreeVisitor visitor]}]
  (-> (cond-> (DirectoryWatcher/builder)
        visitor
        (.fileTreeVisitor visitor))
      (.paths (map to-path paths))
      (.listener (fn->listener cb))
      (.build)))

Does not emit :delete events

NOTE: this is the case on my Apple Silicon Mac using Java 18.

No :type :delete events are emitted for any of the files deleted, unless you first create the file after starting the watcher process and then delete it. Files deleted that were created before invoking the watcher do not emit any events.

The types :create and :update do not seem to suffer from the same issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.