What does it mean to use Ember.K in an if statement? What are some other common ways to use Ember.K?

Ember.K is an empty function, just containing return this .

I noticed that it was used in the if statement of a filter function to save changes to EmberData. This is a filter function :

  if (adapter.shouldSave(record)) { filteredSet.add(record); } 

In adapters (e.g. localstorage adapter ) that do not have their own implementations of shouldSave() , the common shouldSave() only Ember.K . Does this mean that the if statement basically turns into:

  if (true) { filteredSet.add(record); } 

and record always added to the filteredSet .

Please correct me if I am wrong.


What are some other uses of Ember.K?

+4
source share
1 answer

Does this mean that the if statement basically turns into if (true)... :

Yes, that’s what it means.

What are some other uses of Ember.K?

This is basically it. Think of Ember.K as the placeholder used in the base class when defining hooks that should be defined by child classes. Like activate and deactivate hooks in route.js

+5
source

Source: https://habr.com/ru/post/1490008/


All Articles