Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
visualcloud
/
Vmatrix-client-taro
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0f076091
authored
Dec 19, 2019
by
hank
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复event tslint
parent
4241bbb7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
package.json
+1
-0
src/common/events.ts
+7
-2
No files found.
package.json
View file @
0f076091
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
"dev:tt"
:
"npm run build:tt -- --watch"
,
"dev:tt"
:
"npm run build:tt -- --watch"
,
"dev:h5"
:
"npm run build:h5 -- --watch"
,
"dev:h5"
:
"npm run build:h5 -- --watch"
,
"dev:rn"
:
"npm run build:rn -- --watch"
,
"dev:rn"
:
"npm run build:rn -- --watch"
,
"precommit"
:
"npm run lint"
,
"lint"
:
"tslint --project ./tsconfig.json && stylelint
\"
./src/**/*.scss
\"
"
,
"lint"
:
"tslint --project ./tsconfig.json && stylelint
\"
./src/**/*.scss
\"
"
,
"run:shell"
:
"cd ../taro-native-shell/ && yarn android"
"run:shell"
:
"cd ../taro-native-shell/ && yarn android"
},
},
...
...
src/common/events.ts
View file @
0f076091
// tslint:disable:no-invalid-this
// tslint:disable-next-line:only-arrow-functions
const
EventBus
=
(
function
()
{
const
EventBus
=
(
function
()
{
function
EventBusClass
()
{
function
EventBusClass
()
{
this
.
msgQueues
=
{}
this
.
msgQueues
=
{}
...
@@ -18,6 +20,7 @@ const EventBus = (function() {
...
@@ -18,6 +20,7 @@ const EventBus = (function() {
// 消息队列中仅保存一个消息
// 消息队列中仅保存一个消息
one
:
function
(
msgName
,
func
)
{
one
:
function
(
msgName
,
func
)
{
// 无需检查msgName是否存在
// 无需检查msgName是否存在
this
.
msgQueues
[
msgName
]
=
func
this
.
msgQueues
[
msgName
]
=
func
},
},
// 发送消息
// 发送消息
...
@@ -25,6 +28,7 @@ const EventBus = (function() {
...
@@ -25,6 +28,7 @@ const EventBus = (function() {
if
(
!
this
.
msgQueues
.
hasOwnProperty
(
msgName
))
{
if
(
!
this
.
msgQueues
.
hasOwnProperty
(
msgName
))
{
return
return
}
}
if
(
typeof
this
.
msgQueues
[
msgName
]
===
'function'
)
{
if
(
typeof
this
.
msgQueues
[
msgName
]
===
'function'
)
{
this
.
msgQueues
[
msgName
](
msg
)
this
.
msgQueues
[
msgName
](
msg
)
}
else
{
}
else
{
...
@@ -39,11 +43,12 @@ const EventBus = (function() {
...
@@ -39,11 +43,12 @@ const EventBus = (function() {
if
(
!
this
.
msgQueues
.
hasOwnProperty
(
msgName
))
{
if
(
!
this
.
msgQueues
.
hasOwnProperty
(
msgName
))
{
return
return
}
}
delete
this
.
msgQueues
[
msgName
]
delete
this
.
msgQueues
[
msgName
]
}
}
}
}
var
EventBus
=
new
EventBusClass
()
let
Event
=
new
EventBusClass
()
return
Event
Bus
return
Event
})()
})()
export
default
EventBus
export
default
EventBus
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment