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
7aa02017
Commit
7aa02017
authored
Nov 09, 2021
by
Romain Courteaud
Committed by
Gabriel Monnerat
Nov 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to cancel method call in an iframe gadget
parent
f63531f2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
9 deletions
+37
-9
lib/jschannel/jschannel.js
lib/jschannel/jschannel.js
+4
-2
renderjs.js
renderjs.js
+33
-7
No files found.
lib/jschannel/jschannel.js
View file @
7aa02017
...
...
@@ -379,12 +379,12 @@
obj
[
pathItems
[
pathItems
.
length
-
1
]]
=
(
function
()
{
var
cbName
=
path
;
return
function
(
params
)
{
return
trans
.
invoke
(
cbName
,
params
);
return
trans
.
invoke
(
cbName
,
params
,
m
.
id
);
};
})();
}
}
var
resp
=
regTbl
[
method
](
trans
,
m
.
params
);
var
resp
=
regTbl
[
method
](
trans
,
m
.
params
,
m
.
id
);
if
(
!
trans
.
delayReturn
()
&&
!
trans
.
completed
())
trans
.
complete
(
resp
);
}
catch
(
e
)
{
// automagic handling of exceptions:
...
...
@@ -580,6 +580,8 @@
s_curTranId
++
;
postMessage
(
msg
);
// return the transaction id
return
s_curTranId
-
1
;
},
notify
:
function
(
m
)
{
if
(
!
m
)
throw
'
missing arguments to notify function
'
;
...
...
renderjs.js
View file @
7aa02017
...
...
@@ -1022,9 +1022,10 @@
function
handleChannelDeclareMethod
(
trans
,
method_name
)
{
gadget_instance
[
method_name
]
=
function
triggerChannelDeclareMethod
()
{
var
argument_list
=
arguments
,
channel_call_id
,
wait_promise
=
new
RSVP
.
Promise
(
function
handleChannelCall
(
resolve
,
reject
)
{
gadget_instance
.
__chan
.
call
({
channel_call_id
=
gadget_instance
.
__chan
.
call
({
method
:
"
methodCall
"
,
params
:
[
method_name
,
...
...
@@ -1032,6 +1033,15 @@
success
:
resolve
,
error
:
reject
});
},
function
cancelChannelCall
(
msg
)
{
gadget_instance
.
__chan
.
notify
({
method
:
"
cancelMethodCall
"
,
params
:
[
channel_call_id
,
msg
]
});
}
);
...
...
@@ -1883,6 +1893,7 @@
function
finishAqParentConfiguration
(
TmpConstructor
,
root_gadget
,
embedded_channel
)
{
var
transaction_dict
=
{};
// Define __aq_parent to inform parent window
root_gadget
.
__aq_parent
=
TmpConstructor
.
prototype
.
__aq_parent
=
function
aq_parent
(
method_name
,
...
...
@@ -1905,14 +1916,29 @@
};
// bind calls to renderJS method on the instance
embedded_channel
.
bind
(
"
methodCall
"
,
function
methodCall
(
trans
,
v
)
{
embedded_channel
.
bind
(
"
methodCall
"
,
function
methodCall
(
trans
,
v
,
transaction_id
)
{
transaction_dict
[
transaction_id
]
=
root_gadget
[
v
[
0
]].
apply
(
root_gadget
,
v
[
1
])
.
push
(
trans
.
complete
,
function
handleMethodCallError
(
e
)
{
.
push
(
function
handleMethodCallSuccess
()
{
// drop the promise reference, to allow garbage collection
delete
transaction_dict
[
transaction_id
];
trans
.
complete
.
apply
(
trans
,
arguments
);
},
function
handleMethodCallError
(
e
)
{
// drop the promise reference, to allow garbage collection
delete
transaction_dict
[
transaction_id
];
trans
.
error
(
e
.
toString
());
});
trans
.
delayReturn
(
true
);
});
embedded_channel
.
bind
(
"
cancelMethodCall
"
,
function
cancelMethodCall
(
trans
,
v
)
{
if
(
transaction_dict
.
hasOwnProperty
(
v
[
0
]))
{
transaction_dict
[
v
[
0
]].
cancel
(
v
[
1
]);
}
});
}
function
bootstrap
(
url
)
{
...
...
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