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 referencebackgroundapp
accessed viachrome.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
Post a Comment