Skip to content
This repository was archived by the owner on Feb 26, 2022. It is now read-only.

Bug 709382 require("simple-prefs").prefs should be iterable#300

Merged
Gozala merged 24 commits intomozilla:masterfrom
erikvold:bug-709382
Jun 5, 2012
Merged

Bug 709382 require("simple-prefs").prefs should be iterable#300
Gozala merged 24 commits intomozilla:masterfrom
erikvold:bug-709382

Conversation

@erikvold
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferences-service is based on Preferences and is intended to be a cleaner, more friendly, and more JavaScript-y API than the underlying XPCOM interface. I'd like to maintain that friendliness as we add new functionality to it.

In particular, instead of introducing a "class method" that takes a branch name, we should make the exports object be a constructor that retains its existing class methods but also takes a branch name when called as a constructor (just like in Preferences) and from which consumers can retrieve the keys for the branch. And rather than calling the key retrieval method by a non-standard name like getChildList() that comes from the underlying XPCOM API, we should use the standard Object.keys() (like in simple-prefs).

So the API would then look like:

let Prefs = require("preferences-service");
let myPrefs = Prefs("foo.bar.baz");
console.log("My prefs are: " + Object.keys(myPrefs));
// It's still possible to call Prefs.get("foo.bar.baz.qux"), etc.

for.. in can be made to work on these instances, as can branch-scoped versions of the existing class methods like get() and set() (just like in Preferences), but those can happen in a separate change; they don't need to be part of this one.

@erikvold
Copy link
Copy Markdown
Contributor Author

Mind taking a look at this one @Gozala ?

@gregglind
Copy link
Copy Markdown
Contributor

I cleaned this up some and rebased it at #442

(I don't feel like I have authority to close requests here :) )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please change this to Branch(name) instead ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it dc0140b

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please rename pref, val to key value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it.

@Gozala
Copy link
Copy Markdown
Contributor

Gozala commented May 21, 2012

Could we please tackle iterability separately from observability ?

@Gozala
Copy link
Copy Markdown
Contributor

Gozala commented May 30, 2012

Do you plan to address this as well #300 (comment) ?
Also, pull request is out of date you need to merge with current master.

@Gozala
Copy link
Copy Markdown
Contributor

Gozala commented May 30, 2012

Thanks for doing all of these BTW!

@erikvold
Copy link
Copy Markdown
Contributor Author

erikvold commented Jun 2, 2012

merged with master now.

@erikvold
Copy link
Copy Markdown
Contributor Author

erikvold commented Jun 2, 2012

I think this is ready for another review @Gozala

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not alias set / get / keys, ... on Branch constructor.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also we should stick to following export pattern:

function foo() {
  // ...
}
exports.foo = foo;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please make sure to Proxy handler code to use method(branchName + pref) instead of Branch.method(branchName + pref) or exports.method(...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it 07540b3.

@Gozala
Copy link
Copy Markdown
Contributor

Gozala commented Jun 4, 2012

Just a small details left. Thanks ;)

@erikvold
Copy link
Copy Markdown
Contributor Author

erikvold commented Jun 5, 2012

got the rest in 082622f @Gozala

@Gozala
Copy link
Copy Markdown
Contributor

Gozala commented Jun 5, 2012

Looks good, thanks a lot!

Gozala added a commit that referenced this pull request Jun 5, 2012
fix Bug 709382 require("simple-prefs").prefs should be iterable r=@Gozala
@Gozala Gozala merged commit 6e2bb51 into mozilla:master Jun 5, 2012
Gozala added a commit that referenced this pull request Jun 5, 2012
Bug 709382 - Fixing reference to wrong binding error introduced in #300 a=@Gozala
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants