Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
renderjs
Commits
99929f72
Commit
99929f72
authored
Jan 17, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Protect the changeState calls with the 'changestate' mutex.
parent
0b307c54
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
45 deletions
+28
-45
renderjs.js
renderjs.js
+28
-45
No files found.
renderjs.js
View file @
99929f72
...
@@ -698,54 +698,37 @@
...
@@ -698,54 +698,37 @@
return
this
.
element
;
return
this
.
element
;
})
})
.
declareMethod
(
'
changeState
'
,
function
changeState
(
state_dict
)
{
.
declareMethod
(
'
changeState
'
,
function
changeState
(
state_dict
)
{
var
next_onStateChange
=
new
RSVP
.
Queue
(),
var
context
=
this
,
previous_onStateCHange
,
key
,
context
=
this
;
modified
=
false
,
if
(
context
.
hasOwnProperty
(
'
__previous_onStateChange
'
))
{
previous_cancelled
=
context
.
hasOwnProperty
(
'
__modification_dict
'
),
previous_onStateCHange
=
context
.
__previous_onStateChange
;
modification_dict
;
next_onStateChange
if
(
previous_cancelled
)
{
.
push
(
function
waitForPreviousStateChange
()
{
modification_dict
=
context
.
__modification_dict
;
return
previous_onStateCHange
;
modified
=
true
;
}
else
{
modification_dict
=
{};
}
for
(
key
in
state_dict
)
{
if
(
state_dict
.
hasOwnProperty
(
key
)
&&
(
state_dict
[
key
]
!==
context
.
state
[
key
]))
{
context
.
state
[
key
]
=
state_dict
[
key
];
modification_dict
[
key
]
=
state_dict
[
key
];
modified
=
true
;
}
}
if
(
modified
&&
context
.
__state_change_callback
!==
undefined
)
{
context
.
__modification_dict
=
modification_dict
;
return
new
RSVP
.
Queue
()
.
push
(
function
waitForStateChangeCallback
()
{
return
context
.
__state_change_callback
(
modification_dict
);
})
})
.
push
(
undefined
,
function
handlePreviousStateChangeError
(
)
{
.
push
(
function
handleStateChangeSuccess
(
result
)
{
// Run callback even if previous failed
delete
context
.
__modification_dict
;
return
;
return
result
;
});
});
}
}
context
.
__previous_onStateChange
=
next_onStateChange
;
},
{
mutex
:
'
changestate
'
});
return
next_onStateChange
.
push
(
function
checkStateModification
()
{
var
key
,
modified
=
false
,
previous_cancelled
=
context
.
hasOwnProperty
(
'
__modification_dict
'
),
modification_dict
;
if
(
previous_cancelled
)
{
modification_dict
=
context
.
__modification_dict
;
modified
=
true
;
}
else
{
modification_dict
=
{};
}
for
(
key
in
state_dict
)
{
if
(
state_dict
.
hasOwnProperty
(
key
)
&&
(
state_dict
[
key
]
!==
context
.
state
[
key
]))
{
context
.
state
[
key
]
=
state_dict
[
key
];
modification_dict
[
key
]
=
state_dict
[
key
];
modified
=
true
;
}
}
if
(
modified
&&
context
.
__state_change_callback
!==
undefined
)
{
context
.
__modification_dict
=
modification_dict
;
return
new
RSVP
.
Queue
()
.
push
(
function
waitForStateChangeCallback
()
{
return
context
.
__state_change_callback
(
modification_dict
);
})
.
push
(
function
handleStateChangeSuccess
(
result
)
{
delete
context
.
__modification_dict
;
return
result
;
});
}
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// RenderJSGadget.declareAcquiredMethod
// RenderJSGadget.declareAcquiredMethod
...
...
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