= Db.transaction (' People '); varPeoplestore = Tx.objectstore (' People ')); returnPeoplestore. GetAll
(); }). Then (function(People) {console.table (people);});
Group by:To does gourp by we need to create INDEX: Import IDB from ' IDB '; varDbpromise = Idb.open (' test-db ', 3,function(upgradedb) {Switch(upgradedb.oldversion) { Case0:
//Keyval Store is already created at version 1
varKeyvalstore = Upgradedb.createobjectstore (' Keyval ')); Keyvalstore.put ("Wo
Most of the analysis results show that some tasks of the project have unreasonable logic in allocation and work hours, leading to exceptions in the webpart. Usually, the PWA System maintenance staff will be crazy at this time, because no one changes the settings, the server services are normal, and this logical error occurs inadvertently under the project manager. I felt that the last second was still good, and suddenly I got down. (For administrators
')); Peoplestore.put ({name:"John",//name is the keyAge:23, Favoriteanimal:' Cat ' }); Peoplestore.put ({name:"Joe",//name is the keyAge:21, Favoriteanimal:' Cat ' }); Peoplestore.put ({name:"Jie",//name is the keyAge:22, Favoriteanimal:' Dog ' }); Peoplestore.put ({name:"Jay",//name is the keyAge:24, Favoriteanimal:' Dog ' }); returnTx.complete;}). Then (function() {Console.log ("People is added");}); Dbpromise.then (function(db) {vartx = Db.transaction (' People ', ' ReadWrite ');
(' Updatefound ',function(){ //reg.installing is changed })})Api:linkFor the service worker itself:var sw =// ... logs "Installing"/ /// "Installed" // "activating"/ /" avvtivated"// "redundant" Sw.addeventlistener (function() { // Sw.state has changed })Aslo about:Naviagetor.serviceWorker.controller"Navigator.serviceWorker.controller" refer to the service worker, that controls the page.So if there was no controller, then it means the data was loading from network:if (! Naviga
the root scope, so it's available to all the Child components.2. Our service worker file:// Sw.js Self.addeventlistener ('fetch', function (event) { Console.log (event. request);});Once you fetch the page seond time (first time service work do cache stuff), second time you'll see in the console, the Re is lots of requests log out.
Of course, service worker has other event listeners:Self.addeventlistener ('Install', Function (Event) { // ..}); Self.addeventlistener ('Activate', Function
Link to CodelabIn this codelab, we'll retrace those steps but this time we'll use a tool called Sw-precache to add offline functionality With only six lines of code. It's never been easier to add service worker support to an existing app, and we'll show you what in this codelab.Learning:
What's the Sw-precache tool is and how it can help you being more productive
How to add a basic service worker to an existing project using Sw-precache
Install:git clone https://gith
) {returnResponse | |fetch (event.request); }) );});The Servephoto ():We want to make sure-things:
We don ' t care the photo size, 800px,200px or 40px
Because respond object can be is only access once, so we need Clone () the original one and use clone one for the CAHCE, retur n the original one to the browser.
functionServephoto (Request) {varStorageurl = Request.url.replace (/-\d+px\.jpg$/, "); returnCaches.open (Contentimgscache). Then (function(cache) {returnCache.match (S
the create the cache, but it was not a useful until we use the cache.To use the cache, we can do:Self.addeventlistener (' Install ',function(event) {varUrlstocache = [ ‘/‘, ' Js/main.js ', ' Css/main.css ', ' Imgs/icon.png ', ' Https://fonts.gstatic.com/s/roboto/v15/2UX7WLTfW3W8TclTUvlFyQ.woff ', ' Https://fonts.gstatic.com/s/roboto/v15/d-6IYplOFocCacKzxwXSOD8E0i7KZn-EPnyo3HZu7kw.woff ' ]; Event.waituntil (//Todo:open A cache named ' Wittr-static-v1 ' //ADD cache The URLs
Label:Use the library indexeddb-promised. Create a database and Stroe: Import IDB from ' IDB ';
// Open (db_name, version, CB)
var function (upgradedb) {
var// CREATE TABLE
//put (value, key )
keyvalstore.put (' World ', ' Hello ')
; Notice put () function take value frist then key. Read the key in Stroe: // read "Hello" in "Keyval"
Dbpromise.then (function (db) {
var// Open a transaction
var// read the store
return// Get value by key
}). Then (function (val)
When we save items to indexdb, we need to think about clean the items or keep those in a short list.Indexcontroller.prototype._onsocketmessage =function (data) {varMessages =json.parse (data); This. _dbpromise.then (function (db) {if(!DB)return; vartx = Db.transaction ('Wittrs','ReadWrite'); varstore = Tx.objectstore ('Wittrs'); Messages.foreach (function (message) {store.put (message); }); //Todo:keep The newest, entries in ' Wittrs ',//But delete the rest. // //hint:you can use. open
only be used within a function are called "local variables".Note: The var keyword is omitted anywhere, and the variables defined are "global variables" (which can be used outside of the function) so, in general, do not omit the var keyword.Assignment Value and assignment address:Assignment value: Used to assign a basic data type (only one value) to a variable.Reference address: Used to assign a composite data type (possibly with multiple values) to a variable. All two variables change at the sa
OC-class definition and oc-DefinitionWe have already introduced a program HelloWorld: Keep in OC.
The biggest difference between OC and C is that it has the Object-Oriented function. When it comes to object-oriented, we have to talk about the class concept. If we have learned Java, so there is no stranger to the concepts of classes and objects, Because Java is a very pure object-oriented design language. I will not elaborate on the concepts of classe
They have a common advantage is "change the whole, to avoid the input error" What are the two different? Some.The main difference is that the macro definition is done prior to compilation, and the const is processed during the compilation phaseMacros define constants that do not occupy memory cells and are defined by const occupy memory unitsA macro definition has the same effect as a const constant-----t
C ++ macro definition commands and macro definition commandsCommands starting with # In a program are pre-compiled commands. There are three types of pre-compiled commands: macro definition commands, file inclusion commands, and Conditional compilation commands. Today we will talk about macro definition: macro
11-4. Call another model definition function in the model definition functionProblemWant to use a "model definition" function to implement another "model definition" functionSolution SolutionsLet's say we already have a corporate partnership together with their structural model, as Figure 11-4 shows:Figure 11-4. a mode
Common Function Definition methods of JavaScript, javascript function definition
This article describes various common function definition methods in JavaScript for your reference. The specific analysis is as follows:
First, let's take a look at the four most common function definitions in JavaScript:
Use Function to construct a Function defined by a Function. Th
Recently, when I was working on the preliminary code architecture of the cloud platform, I encountered a constant definition speed comparison problem, so I would like to make a comparison.The APC extension of PHP is described in the following section in the PHP manual:Http://cn.php.net/manual/zh/function.apc-define-constants.phpDefine () is notoriously slow. Since the main benefit of APC is to increase the performance of scripts/applications, this mec
Json definition and jquery json method, json definition jquery operation
I. background
Json is a lightweight data exchange format that facilitates interaction between java services and js. This article will introduce the simple definition of json and how js parses json.
Ii. Content
1. json definition:
The simple json f
//A.cppclassa{ Public: intFunintx) { return(x*x+ +); } }; voidtt () {}//B.cppclassa{ Public: intFunintx); }; voidtt (); intyy () {TT (); A; returnA.fun (3); }Compile them and then link them separately:A link error was displayed because a reference to A::fun (int) could not be found in B.cpp (B.O).Change the a.cpp above to read as follows:Class a{ public: int fun (intint A:: Fun (int x) { return (x*x+); } void tt () { } Compile the a.cpp again wit
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.