{"action":"created","issue":{"url":"https://api.github.com/repos/Kinto/kinto.js/issues/392","repository_url":"https://api.github.com/repos/Kinto/kinto.js","labels_url":"https://api.github.com/repos/Kinto/kinto.js/issues/392/labels{/name}","comments_url":"https://api.github.com/repos/Kinto/kinto.js/issues/392/comments","events_url":"https://api.github.com/repos/Kinto/kinto.js/issues/392/events","html_url":"https://github.com/Kinto/kinto.js/issues/392","id":148360629,"number":392,"title":"[fx-src] Pass FFx dependencies to loadKinto","user":{"login":"n1k0","id":41547,"avatar_url":"https://avatars.githubusercontent.com/u/41547?v=3","gravatar_id":"","url":"https://api.github.com/users/n1k0","html_url":"https://github.com/n1k0","followers_url":"https://api.github.com/users/n1k0/followers","following_url":"https://api.github.com/users/n1k0/following{/other_user}","gists_url":"https://api.github.com/users/n1k0/gists{/gist_id}","starred_url":"https://api.github.com/users/n1k0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n1k0/subscriptions","organizations_url":"https://api.github.com/users/n1k0/orgs","repos_url":"https://api.github.com/users/n1k0/repos","events_url":"https://api.github.com/users/n1k0/events{/privacy}","received_events_url":"https://api.github.com/users/n1k0/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-14T13:26:28Z","updated_at":"2016-04-14T13:36:30Z","closed_at":null,"body":"The idea whould be to allow delegating the creation/retrieval of Gecko specific modules in Firefox itself and pass them to `loadKinto`.\r\n\r\nThoughts? \r\n\r\nBefore:\r\n\r\n```js\r\nexport default function loadKinto() {\r\n  const { EventEmitter } = Cu.import(\"resource://devtools/shared/event-emitter.js\", {});\r\n  const { generateUUID } = Cc[\"@mozilla.org/uuid-generator;1\"].getService(Ci.nsIUUIDGenerator);\r\n\r\n  // Use standalone kinto-client module landed in FFx.\r\n  const { KintoHttpClient } = Cu.import(\"resource://services-common/kinto-http-client.js\");\r\n\r\n  Cu.import(\"resource://gre/modules/Timer.jsm\");\r\n  Cu.importGlobalProperties(['fetch']);\r\n  \r\n  ...\r\n```\r\n\r\nAfter\r\n\r\n```js\r\nexport default function loadKinto({fetch, generateUUID, Timer, EventEmitter, KintoHttpClient}) {\r\n  ...\r\n```\r\n\r\nAnd in Gecko land:\r\n\r\n```js\r\nconst { EventEmitter } = Cu.import(\"resource://devtools/shared/event-emitter.js\", {});\r\nconst { generateUUID } = Cc[\"@mozilla.org/uuid-generator;1\"].getService(Ci.nsIUUIDGenerator);\r\nconst { KintoHttpClient } = Cu.import(\"resource://services-common/kinto-http-client.js\");\r\nCu.import(\"resource://gre/modules/Timer.jsm\");\r\nCu.importGlobalProperties(['fetch']);\r\n\r\nloadKinto({\r\n  EventEmitter,\r\n  generateUUID,\r\n  KintoHttpClient,\r\n  Timer,\r\n  fetch\r\n});\r\n```\r\n\r\nOne of the most immediate benefit would be to not have any Firefox specific imports in there.\r\n\r\nThoughts? @leplatrem @mozmark "},"comment":{"url":"https://api.github.com/repos/Kinto/kinto.js/issues/comments/209944779","html_url":"https://github.com/Kinto/kinto.js/issues/392#issuecomment-209944779","issue_url":"https://api.github.com/repos/Kinto/kinto.js/issues/392","id":209944779,"user":{"login":"leplatrem","id":546692,"avatar_url":"https://avatars.githubusercontent.com/u/546692?v=3","gravatar_id":"","url":"https://api.github.com/users/leplatrem","html_url":"https://github.com/leplatrem","followers_url":"https://api.github.com/users/leplatrem/followers","following_url":"https://api.github.com/users/leplatrem/following{/other_user}","gists_url":"https://api.github.com/users/leplatrem/gists{/gist_id}","starred_url":"https://api.github.com/users/leplatrem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leplatrem/subscriptions","organizations_url":"https://api.github.com/users/leplatrem/orgs","repos_url":"https://api.github.com/users/leplatrem/repos","events_url":"https://api.github.com/users/leplatrem/events{/privacy}","received_events_url":"https://api.github.com/users/leplatrem/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T13:36:30Z","updated_at":"2016-04-14T13:36:30Z","body":"For `Timer` it does not look so obvious and should be splitted into `setTimeout`, `setInterval`...\r\n\r\nThen in the `loadKinto` you'll have to pass the reference to those everywhere underneath, unless to assign them to some global :/\r\n\r\nAt first sight, appart from module loading optimization, I don't see too much value :blush: \r\n\r\n"}}