What order are knockout js observable extensions executed?

后端 未结 2 1726
长发绾君心
长发绾君心 2021-01-22 03:03

At the bottom of the knockoutjs docs for extending observables it states...

More than one extender can be applied in a single call to the .extend method of a

2条回答
  •  时光取名叫无心
    2021-01-22 03:22

    If the order is important, you can call extend multiple times:

    this.firstName = ko.observable(first)
        .extend({ required: "Please enter a first name" })
        .extend({ logChange: "first name" });
    

    That being said, browsers generally process an object's properties in the same order they were defined. Thus your original method will have the same effect as this one.

提交回复
热议问题