在if语句中使用Ember.K是什么意思?使用Ember.K还有哪些其他常用方法?

Hao*_* Li 4 ember.js

Ember.K是一个空函数,只包含return this.

我观察到它在过滤器函数的if语句中用于保存对EmberData的更改.这是过滤功能:

    if (adapter.shouldSave(record)) {
      filteredSet.add(record);
    }
Run Code Online (Sandbox Code Playgroud)

在缺少自己的实现的适配器(例如localstorage适配器)中,使用just shouldSave()泛型shouldSave()Ember.K.那么这是否意味着if语句基本上变成了:

    if (true) {
      filteredSet.add(record);
    }
Run Code Online (Sandbox Code Playgroud)

并且record总是添加到filteredSet.

如果我错了,请纠正我.


Ember.K还有哪些其他用途?

Mik*_*tti 5

那么这是否意味着if语句基本上变成了if (true)...:

是的,这正是它的含义.

Ember.K还有哪些其他用途?

基本上就是这样.想的Ember.K为限定应该由子类来定义的钩时在基类中使用的占位符.就像route.js中activatedeactivate钩子一样