from r2.lib.plugin import Plugin
from r2.lib.js import Module


class Adzerk(Plugin):
    needs_static_build = True

    js = {
        'reddit': Module('reddit.js',
            'adzerk/adzerk.js',
        )
    }

    def load_controllers(self):
        # replace the standard Ads view with an Adzerk specific one.
        import r2.lib.pages.pages
        from adzerkads import Ads as AdzerkAds
        r2.lib.pages.pages.Ads = AdzerkAds

from r2.lib.plugin import Plugin
from r2.lib.js import Module


class Adzerk(Plugin):
    needs_static_build = True

    js = {
        'reddit-init': Module('reddit-init.js',
            'adzerk/adzerk.js',
        )
    }

    def load_controllers(self):
        # replace the standard Ads view with an Adzerk specific one.
        import r2.lib.pages.pages
        from adzerkads import Ads as AdzerkAds
        r2.lib.pages.pages.Ads = AdzerkAds

Move adzerk.js into reddit-init to fix race condition.
Move adzerk.js into reddit-init to fix race condition.

This should ensure that the Adzerk postMessage receiver is loaded before
Adzerk gets its payloads.

  from r2.lib.plugin import Plugin
  from r2.lib.js import Module
  
  
  class Adzerk(Plugin):
      needs_static_build = True
  
      js = {
-         'reddit': Module('reddit.js',
+         'reddit-init': Module('reddit-init.js',
              'adzerk/adzerk.js',
          )
      }
  
      def load_controllers(self):
          # replace the standard Ads view with an Adzerk specific one.
          import r2.lib.pages.pages
          from adzerkads import Ads as AdzerkAds
          r2.lib.pages.pages.Ads = AdzerkAds
  
Move adzerk.js into reddit-init to fix race condition.
## Code Before:
from r2.lib.plugin import Plugin
from r2.lib.js import Module


class Adzerk(Plugin):
    needs_static_build = True

    js = {
        'reddit': Module('reddit.js',
            'adzerk/adzerk.js',
        )
    }

    def load_controllers(self):
        # replace the standard Ads view with an Adzerk specific one.
        import r2.lib.pages.pages
        from adzerkads import Ads as AdzerkAds
        r2.lib.pages.pages.Ads = AdzerkAds

## Instruction:
Move adzerk.js into reddit-init to fix race condition.
## Code After:
from r2.lib.plugin import Plugin
from r2.lib.js import Module


class Adzerk(Plugin):
    needs_static_build = True

    js = {
        'reddit-init': Module('reddit-init.js',
            'adzerk/adzerk.js',
        )
    }

    def load_controllers(self):
        # replace the standard Ads view with an Adzerk specific one.
        import r2.lib.pages.pages
        from adzerkads import Ads as AdzerkAds
        r2.lib.pages.pages.Ads = AdzerkAds
