11/*!
2- * Mpstore.js v0.2.1
2+ * Mpstore.js v0.2.3
33 * (c) 2019-2020 Imtaotao
44 * Released under the MIT License.
55 */
@@ -558,6 +558,8 @@ class TimeTravel {
558558
559559var defaultOption = {
560560 env : 'develop' ,
561+ storeNamespace : 'store' ,
562+ globalNamespace : 'global' ,
561563} ;
562564
563565const COMMONACTION = ( ) => { } ;
@@ -701,14 +703,14 @@ class Store {
701703 this . reducers = [ ] ;
702704 this . id = ++ storeId ;
703705 this . depComponents = [ ] ;
704- this . GLOBALWORD = 'global' ;
705706 this . isDispatching = false ;
706707 this . restoreCallbacks = [ ] ;
707708 this . dispatchCallbacks = [ ] ;
708- this . version = '0.2.1 ' ;
709+ this . version = '0.2.3 ' ;
709710 this . state = Object . freeze ( createModule ( { } ) ) ;
710711 this . middleware = new Middleware ( this ) ;
711- this . options = Object . assign ( defaultOption , options ) ;
712+ this . options = Object . assign ( { } , defaultOption , options ) ;
713+ this . GLOBALWORD = this . options . globalNamespace ;
712714 }
713715 add ( action , reducer ) {
714716 const env = this . options . env ;
@@ -843,7 +845,10 @@ class Store {
843845 key && typeof key === 'string' ,
844846 'The [namespace] must be a string' ,
845847 ) ;
846- this . GLOBALWORD = key ;
848+ if ( this . options . env === 'develop' ) {
849+ console . error ( 'The `setNamespace` is deprecated, please use options to specify.' ) ;
850+ }
851+ this . options . globalNamespace = this . GLOBALWORD = key ;
847852 }
848853 getModule ( namespace , remainMsg ) {
849854 assert (
@@ -888,6 +893,7 @@ class Store {
888893 const store = this ;
889894 const GLOBALWORD = this . GLOBALWORD ;
890895 const { data, storeConfig = { } } = config ;
896+ const storeNamespace = this . options . storeNamespace ;
891897 const {
892898 addDep,
893899 useState,
@@ -962,7 +968,7 @@ class Store {
962968 } ;
963969 function onLoad ( ) {
964970 addDepToStore ( this ) ;
965- this . store = store ;
971+ this [ storeNamespace ] = store ;
966972 this . _$loaded = true ;
967973 }
968974 function onUnload ( ) {
@@ -982,7 +988,7 @@ class Store {
982988 }
983989}
984990
985- const version = '0.2.1 ' ;
991+ const version = '0.2.3 ' ;
986992const nativePage = Page ;
987993const nativeComponent = Component ;
988994function expandConfig ( config , expandMethods , isPage ) {
0 commit comments