Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
matrix-react-sdk
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
Matrix.org
matrix-react-sdk
Commits
3d8d9bac
Commit
3d8d9bac
authored
9 years ago
by
David Baker
Browse files
Options
Downloads
Patches
Plain Diff
Allow the dispatcher to dispatch sync if required.
parent
1041ee65
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dispatcher.js
+19
-6
19 additions, 6 deletions
src/dispatcher.js
with
19 additions
and
6 deletions
src/dispatcher.js
+
19
−
6
View file @
3d8d9bac
...
...
@@ -19,13 +19,26 @@ limitations under the License.
var
flux
=
require
(
"
flux
"
);
class
MatrixDispatcher
extends
flux
.
Dispatcher
{
dispatch
(
payload
)
{
// We always set a timeout to do this: The flux dispatcher complains
/**
* @param {Object} payload Required. The payload to dispatch.
* Must contain at least an 'action' key.
* @param {boolean} sync Optional. Pass true to dispatch
* synchronously. This is useful for anything triggering
* an operation that the browser requires user interaction
* for.
*/
dispatch
(
payload
,
sync
)
{
if
(
sync
)
{
super
.
dispatch
(
payload
);
}
else
{
// Unless the caller explicitly asked for us to dispatch synchronously,
// we always set a timeout to do this: The flux dispatcher complains
// if you dispatch from within a dispatch, so rather than action
// handlers having to worry about not calling anything that might
// then dispatch, we just do dispatches asynchronously.
setTimeout
(
super
.
dispatch
.
bind
(
this
,
payload
),
0
);
}
}
};
if
(
global
.
mxDispatcher
===
undefined
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment