Git Product home page Git Product logo

Comments (3)

WickyNilliams avatar WickyNilliams commented on August 15, 2024

Hey Stefan!

Have you just tried calling listen ahead of any registration? If enquire is listening, each time a handler is added, providing the query matches, it's match callback will be fired immediately.

See this fiddle: http://jsfiddle.net/KjtRD/3/

I meant fire to be used for fine grained control but it seems 99.9% of the time people just use listen (as it reacts to future changes, rather than just assessing state at current point in time). In the upcoming version of enquire i've dropped both of these methods to simplify the API and make life easier for everyone. In this upcoming version it should always work as expected, no more silly edge cases like this one :)

If you're happy with the results of the fiddle above let me know and i'll close the issue

from enquire.js.

StefanWallin avatar StefanWallin commented on August 15, 2024

Hah!
That's exactly what I wanted. Thanks for the quick reply! Good ideas on simplifying the API. Just might need to update the documentation and maybe add this use case there for good measure :)

Have a great one!

from enquire.js.

WickyNilliams avatar WickyNilliams commented on August 15, 2024

No problems :)

Don't worry, updating the docs is taking infinitely longer than the coding, I've been slowly working on it for a long while. If you'd like to test out enquire v2, take a look at the experimental branch.

The differences are no more fire or listen, and that (internally) it doesn't use resize events any more, instead relying entirely on the matchMedia API. This means it should perform better, and that it's even smaller than before :) However it does mean you may have to supply to a matchMedia.addListener polyfill also (which can be found in the matchMedia polyfill repo).

from enquire.js.

Related Issues (20)

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.