Socket
Socket
Sign inDemoInstall

alpinejs-force-next-tick

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    alpinejs-force-next-tick

Alpine JS implementation of the double `requestAnimationFrame` method to force`$nextTick`


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Alpine JS Force $nextTick

Alpine JS implementation of the double requestAnimationFrame method to force $nextTick


You can find out more about the issue in Vue here - https://github.com/vuejs/vue/issues/9200

Vue JS version - https://github.com/twickstrom/vue-force-next-tick

Install

With a CDN

<script
  defer
  src="https://unpkg.com/alpinejs-force-next-tick@latest/dist/force-next-tick.min.js"
></script>

<script defer src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"></script>

With a Package Manager

yarn add -D alpinejs-force-next-tick

npm install -D alpinejs-force-next-tick
import Alpine from 'alpinejs'
import force-next-tick from 'alpinejs-force-next-tick'

Alpine.plugin(force-next-tick)

Alpine.start()

Example

It works the same way as Alpine JS $nextTick but uses the double requestAnimationFrame method - https://alpinejs.dev/magics/nextTick

<body x-data="{ firstName: 'John' }">
  <button
    @click="
      firstName = 'Jane'
      $forceNextTick(() => console.log($el.innerText))
    "
    x-text="firstName"
  >
  </button>
</body>

Here we are pausing an async function until after pending DOM updates. With this approach an argument is not required.

<body x-data="{ firstName: 'John' }">
  <button
    @click="
      firstName = 'Jane'
      await $forceNextTick()
      console.log($el.innerText)
    "
    x-text="firstName"
  >
  </button>
</body>

Stats

Keywords

FAQs

Last updated on 04 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc