Bladeren bron

website: Add core `store` option to API docs

Renée Kooi 7 jaren geleden
bovenliggende
commit
2d6d02255a
2 gewijzigde bestanden met toevoegingen van 14 en 1 verwijderingen
  1. 4 0
      src/store/DefaultStore.js
  2. 10 1
      website/src/docs/uppy.md

+ 4 - 0
src/store/DefaultStore.js

@@ -1,3 +1,6 @@
+/**
+ * Default store that keeps state in a simple object.
+ */
 module.exports = class DefaultStore {
 module.exports = class DefaultStore {
   constructor () {
   constructor () {
     this.state = {}
     this.state = {}
@@ -19,6 +22,7 @@ module.exports = class DefaultStore {
   subscribe (listener) {
   subscribe (listener) {
     this.callbacks.push(listener)
     this.callbacks.push(listener)
     return () => {
     return () => {
+      // Remove the listener.
       this.callbacks.splice(
       this.callbacks.splice(
         this.callbacks.indexOf(listener),
         this.callbacks.indexOf(listener),
         1
         1

+ 10 - 1
website/src/docs/uppy.md

@@ -22,7 +22,8 @@ const uppy = Uppy({
   meta: {},
   meta: {},
   onBeforeFileAdded: (currentFile, files) => Promise.resolve(),
   onBeforeFileAdded: (currentFile, files) => Promise.resolve(),
   onBeforeUpload: (files, done) => Promise.resolve(),
   onBeforeUpload: (files, done) => Promise.resolve(),
-  locale: defaultLocale
+  locale: defaultLocale,
+  store: defaultStore()
 })
 })
 ```
 ```
 
 
@@ -126,6 +127,14 @@ locale: {
 
 
 We are using a forked [Polyglot.js](https://github.com/airbnb/polyglot.js/blob/master/index.js#L37-L60).
 We are using a forked [Polyglot.js](https://github.com/airbnb/polyglot.js/blob/master/index.js#L37-L60).
 
 
+## `store: defaultStore()`
+
+The Store to use to keep track of internal state. By default, a simple object is used.
+This option can be used to plug Uppy state into an external state management library, such as Redux.
+Then, you can write custom views with the library that is also used by the rest of the application.
+
+<!-- TODO document store API -->
+
 ## Methods
 ## Methods
 
 
 ### `uppy.use(plugin, opts)`
 ### `uppy.use(plugin, opts)`