Skip to content

[Feature Request] Helpful util to add and clear the last task #93

Open
@tusharmath

Description

@tusharmath

The usecase is to throttle touchmove events in the dom. As of now we have to schedule it via mutate and then clear it when the next one comes. This can't be done easily and one needs to write a wrapper sort of like this —

function mutateLatest () {
  let id = null
  return function (task) {
   if(id) fastdom.clear(id)
   id = fastdom.mutate(task)
  }
}

The second problem is that it should be performing poorer because of the time complexity of n to remove an element from the queue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions