Browse Source

playing with API in Dummy

Artur Paikin 8 years ago
parent
commit
448e7a5097
1 changed files with 11 additions and 41 deletions
  1. 11 41
      src/plugins/Dummy.js

+ 11 - 41
src/plugins/Dummy.js

@@ -7,12 +7,12 @@ import html from '../core/html'
  *
  *
  */
  */
 class Dummy extends Plugin {
 class Dummy extends Plugin {
-  constructor (core, opts, props) {
+  constructor (core, opts) {
     super(core, opts)
     super(core, opts)
     this.type = 'acquirer'
     this.type = 'acquirer'
     this.id = 'Dummy'
     this.id = 'Dummy'
     this.title = 'Mr. Plugin'
     this.title = 'Mr. Plugin'
-    this.props = props
+    // this.props = props
 
 
     // set default options
     // set default options
     const defaultOptions = {}
     const defaultOptions = {}
@@ -40,7 +40,7 @@ class Dummy extends Plugin {
     this.props.addFile(file)
     this.props.addFile(file)
   }
   }
 
 
-  render () {
+  render (state) {
     const bla = html`<h2>this is strange 2</h2>`
     const bla = html`<h2>this is strange 2</h2>`
     return html`
     return html`
       <div class="wow-this-works">
       <div class="wow-this-works">
@@ -49,56 +49,26 @@ class Dummy extends Plugin {
         }} />
         }} />
         ${this.strange}
         ${this.strange}
         ${bla}
         ${bla}
+        ${state.dummy.text}
       </div>
       </div>
     `
     `
   }
   }
 
 
-  // focus () {
-  //   return
-  //   console.log(`${this.target} .UppyDummy-firstInput`)
-  //
-  //   const firstInput = document.querySelector(`${this.target} .UppyDummy-firstInput`)
-  //
-  //   // only works for the first time if wrapped in setTimeout for some reason
-  //   // firstInput.focus()
-  //   setTimeout(function () {
-  //     firstInput.focus()
-  //   }, 10)
-  //
-  //   setTimeout(() => {
-  //     this.core.emit('informer', 'Hello! I’m a test Informer message', 'info', 4500)
-  //     this.addFakeFileJustToTest()
-  //   }, 1000)
-  // }
-
   install () {
   install () {
+    this.core.setState({dummy: {text: '123'}})
+
     const target = this.opts.target
     const target = this.opts.target
     const plugin = this
     const plugin = this
     this.target = this.mount(target, plugin)
     this.target = this.mount(target, plugin)
 
 
-    // function workerFunc () {
-    //   self.addEventListener('message', (e) => {
-    //     const file = e.data.file
-    //     const reader = new FileReaderSync()
-    //     const dataURL = reader.readAsDataURL(file)
-    //     postMessage({file: dataURL})
-    //   })
-    // }
-    //
-    // const worker = createInlineWorker(workerFunc)
-    // const testFileBlob = new Blob(
-    //   ['data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+CiAgPGNpcmNsZSBjeD0iNjAiIGN5PSI2MCIgcj0iNTAiLz4KPC9zdmc+Cg=='],
-    //   {type: 'image/svg+xml'}
-    // )
-    // worker.postMessage({file: testFileBlob})
-    // worker.addEventListener('message', (e) => {
-    //   console.log(e)
-    // })
+    setTimeout(() => {
+      this.core.setState({dummy: {text: '!!!'}})
+    }, 2000)
   }
   }
 }
 }
 
 
-export default function (core, opts, props) {
+export default function (core, opts) {
   if (!(this instanceof Dummy)) {
   if (!(this instanceof Dummy)) {
-    return new Dummy(core, opts, props)
+    return new Dummy(core, opts)
   }
   }
 }
 }