model view controller - Accessing objects defined in main addon script from content and page scripts in Firefox addons -


i making bootstrapped extension firefox (actually, trying port working chrome extension). in chrome was:

  • background page holds backgroundapp instance of marionette.application , modules hold backbone models of data , storage , sync stuff.
  • popup page holds popupapp instance of marionette.application , modules take care of ui views , routers defined in them. data, popup uses reference backgroundapp accessed via chrome.extension.getbackgroundpage().

now having hard time finding how can pass models popup panel code in firefox, messaging mechanisms i've encountered far take jsonable data.

you have no joy if you're trying use javascript frameworks in firefox addons. @ least if you're using them beyond scope of single window object.

there multiple different, isolated environments in scripts run. if take e10s (multi-process firefox) consideration addon main code run in parent process while interacts page content run in content process(es).

message-passing way interact between environments, , while possible have remote proxies complex objects cause considerable performance penalty , usage discouraged.

so can have backbone/marionette stuff run in panel or in invisible page (that's background page api does?) if want have them communicate each other have data serialiazable shape.

depending on needs might sufficient if implement copy constructors models. i.e. constructors optionally take plain javascript objects (bags of values) , re-create typed models that. requires objects can reconstructed based on enumerable own-properties.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -