Cant find info on missing exports; BindingEngine, TaskQueue

BindingEngine and TaskQueue are not exported by the ‘aurelia’ module. I still have access to ‘aurelia-framework’, I don’t know if this module is meant at a compatibility layer, but it exposes stuff like the @computedFrom decorated, so my guess is, that its not? Basically the question is whether taskqueue and bindingengine have been deprecated and whether or not I should be using the ‘aurelia-framework’ import or not?

I kind answer some of your quesions

TaskQueue

If I understand correctly, this is the “replacement” (also works async)

// Queue
const task = PLATFORM.taskQueue.queueTask(() => {
  doStuff();
}, { delay: 100 });

// Cancel
task.cancel();
import aurelia-framework

aurelia-framework is what we refer to as Aurelia v1, thus the aurelia module is not a compatibility layer.

@computedFrom

https://docs.aurelia.io/side-by-side-comparison/binding#computedfrom

In Aurelia 2, The framework automatically computes observation without the need for any configuration or decorator.


Left for someone else to answer is the BindingEngine point

1 Like

@jrl If you need the BindingEngine to observe properties, then Au2 provides a IObserverLocator. You can get it injected like this:

import { IObserverLocator } from '@aurelia/runtime';
class MyEl {
  public constructor(
   @IObserverLocator private readonly observerLocator: IObserverLocator,
  ){
    observerLocator.getObserver(obj, propertyName)
       .subscribe(this);
  }

  handleChange(newValue, oldValue): void {
    // this gets invoked by the observer if the value of the propertyName in the obj changes.
  }
}

Moreover, if property observation is solely your target then I would recommend simply to use the @watch decorator. That will makes things far easier for you. Here is the link to the docs.

However, if you have other usage for the BindingEngine, can you please provide with some details?

Thank you so much for the help, would have been a bit lost without this.

1 Like

Thanks a bunch, this is exactly what I was looking for. You guys are great!

2 Likes