Comments (7)
Ah yeah because _applyToForm
is a static method. You can changed it to be a regular method and change its calls from OptionsSync._applyToForm
to this._applyToForm
Also
- _log(method, list = []) {
+ _log(method, ...args) {
And
- this._log("info", ["Current options:", options]);
+ this._log('info', 'Current options:', options);
from webext-options-sync.
Makes sense! It can be added as an option to new OptionSync(key, {logging: false})
so it's shared across all the methods.
from webext-options-sync.
Yeah, that can be done too!
Should I create a PR for this? I have looked at code and I'm guessing it's a simple if (logging === true)
check that we need to add before logging any info/warning to the console.
from webext-options-sync.
It's probably best to have an overridable logging function so we don't have to use if
every time. Something like:
constructor(options) {
this.storageName = options.storageName || 'options';
if (options.logging === false) {
this._log = () => {};
}
}
_log() {
console.log(...arguments);
}
from webext-options-sync.
Yes of course, much neater.
from webext-options-sync.
Hey, I'm having some trouble getting the _log
function correctly called from other methods in the class. The constructor and log function:
constructor(options = {}) {
this.storageName = options.storageName || 'options';
if (options.logging === false) {
this._log = () => {};
}
}
_log(method, list = []) {
console[method](...list);
}
and it should be called like so:
this._log("info", ["Current options:", options]);
However, I'm getting the following TypeError when trying it on an extension of my own locally:
Uncaught (in promise) TypeError: this._log is not a function
at Function._applyToForm (content.js:188)
I'm guessing it's got to do with the scope of this
changing, but I'm not sure.
from webext-options-sync.
Thanks! Please publish to npm too
from webext-options-sync.
Related Issues (20)
- Migrations/defaults aren't set for developer extensions at launch
- `chrome.storage.sync.set` errors aren't caught
- Add mechanism to show that field was saved HOT 1
- Latest version (0.21.2) causes error "Uncaught (in promise)" HOT 2
- Add config for compressing options before chrome.sync.set HOT 6
- Remove defaults from stored options
- Form values set to `undefined` HOT 3
- Race condition in OptionsSync constructor HOT 1
- Migrations receive the old options + the new defaults
- Sync options to a third party HOT 4
- Add true ES module
- Move from Travis to GitHub Actions HOT 1
- Values from the store are cleared on page refresh (when trying to save `Set`) HOT 4
- Async migrations HOT 1
- Migrations fail on Safari
- Options type does not allow nested object or array keys HOT 3
- Allow post-processing of form data HOT 2
- "Change" event to subscribe to so extension pages can update each other HOT 2
- Use `onContextInvalidated` to add banner inviting the user to reload the page (or just reload it)
- `showSaveFilePicker` broken in some browsers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webext-options-sync.