Browse Source

plugin.update() experiments

Artur Paikin 8 years ago
parent
commit
9ea27f544b
1 changed files with 25 additions and 6 deletions
  1. 25 6
      src/plugins/Plugin.js

+ 25 - 6
src/plugins/Plugin.js

@@ -1,4 +1,7 @@
 const yo = require('yo-yo')
+// const nanoraf = require('nanoraf')
+
+window.updateNum = 0
 
 /**
  * Boilerplate that all Plugins share - and should not be used
@@ -23,6 +26,8 @@ module.exports = class Plugin {
     this.mount = this.mount.bind(this)
     this.focus = this.focus.bind(this)
     this.install = this.install.bind(this)
+
+    // this.frame = null
   }
 
   update (state) {
@@ -30,14 +35,28 @@ module.exports = class Plugin {
       return
     }
 
-    // const newEl = this.render(state)
-    // yo.update(this.el, newEl)
+    // const prev = {}
+    // if (!this.frame) {
+    //   console.log('creating frame')
+    //   this.frame = nanoraf((state, prev) => {
+    //     console.log('updating!', Date.now())
+    //     const newEl = this.render(state)
+    //     this.el = yo.update(this.el, newEl)
+    //   })
+    // }
+    // console.log('attempting an update...', Date.now())
+    // this.frame(state, prev)
+
+    this.core.log('update number: ' + window.updateNum++)
+
+    const newEl = this.render(state)
+    yo.update(this.el, newEl)
 
     // optimizes performance?
-    requestAnimationFrame(() => {
-      const newEl = this.render(state)
-      yo.update(this.el, newEl)
-    })
+    // requestAnimationFrame(() => {
+    //   const newEl = this.render(state)
+    //   yo.update(this.el, newEl)
+    // })
   }
 
   /**