I
I
ijakparov2017-01-22 09:45:44
JavaScript
ijakparov, 2017-01-22 09:45:44

How to use YM modules?

When using i-bem.js technology, you have to use YM modules.
Modules in dependencies that have i-bem are executed without using module.require, it is enough to declare them through define. There are cases when there is no need to specify i-bem in the dependencies and you just need to write the YM module, does it turn out that it should be launched immediately after the declaration?
Example: It is
necessary to display alert on the page. In YM modules it looks like this:

modules.define('WOW', function(provide) {

  provide({
    init_wow : function() { 
      alert(123);
    }
  });

});

modules.require('WOW',function(init){
  init.init_wow();
});

it turns out that I need to describe the module and immediately call it. Is it normal to do this at all?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ijakparov, 2017-01-22
@ijakparov

Just realized that the record can be shortened to

modules.define('WOW', function(provide) {

  alert(22222);

});

modules.require('WOW');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question