Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
331d19ff
Unverified
Commit
331d19ff
authored
Oct 29, 2019
by
Jonah Williams
Committed by
GitHub
Oct 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add reloadMethod RPC (#43725)
parent
1d7afd9c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
9 deletions
+56
-9
vmservice.dart
packages/flutter_tools/lib/src/vmservice.dart
+41
-8
vmservice_test.dart
...ages/flutter_tools/test/general.shard/vmservice_test.dart
+15
-1
No files found.
packages/flutter_tools/lib/src/vmservice.dart
View file @
331d19ff
...
...
@@ -123,16 +123,9 @@ class VMService {
final
bool
force
=
params
.
asMap
[
'force'
]
??
false
;
final
bool
pause
=
params
.
asMap
[
'pause'
]
??
false
;
if
(
isolateId
is
!
String
||
isolateId
.
isEmpty
)
{
if
(
isolateId
.
isEmpty
)
{
throw
rpc
.
RpcException
.
invalidParams
(
'Invalid
\'
isolateId
\'
:
$isolateId
'
);
}
if
(
force
is
!
bool
)
{
throw
rpc
.
RpcException
.
invalidParams
(
'Invalid
\'
force
\'
:
$force
'
);
}
if
(
pause
is
!
bool
)
{
throw
rpc
.
RpcException
.
invalidParams
(
'Invalid
\'
pause
\'
:
$pause
'
);
}
try
{
await
reloadSources
(
isolateId
,
force:
force
,
pause:
pause
);
return
<
String
,
String
>{
'type'
:
'Success'
};
...
...
@@ -148,6 +141,46 @@ class VMService {
'service'
:
'reloadSources'
,
'alias'
:
'Flutter Tools'
,
});
// Register a special method for hot UI. while this is implemented
// currently in the same way as hot reload, it leaves the tool free
// to change to a more efficient implementation in the future.
_peer
.
registerMethod
(
'reloadMethod'
,
(
rpc
.
Parameters
params
)
async
{
final
String
isolateId
=
params
[
'isolateId'
].
value
;
final
String
libraryId
=
params
[
'library'
].
value
;
final
String
classId
=
params
[
'class'
].
value
;
final
String
methodId
=
params
[
'method'
].
value
;
final
String
methodBody
=
params
[
'methodBody'
].
value
;
if
(
libraryId
.
isEmpty
)
{
throw
rpc
.
RpcException
.
invalidParams
(
'Invalid
\'
libraryId
\'
:
$libraryId
'
);
}
if
(
classId
.
isEmpty
)
{
throw
rpc
.
RpcException
.
invalidParams
(
'Invalid
\'
classId
\'
:
$classId
'
);
}
if
(
methodId
.
isEmpty
)
{
throw
rpc
.
RpcException
.
invalidParams
(
'Invalid
\'
methodId
\'
:
$methodId
'
);
}
if
(
methodBody
.
isEmpty
)
{
throw
rpc
.
RpcException
.
invalidParams
(
'Invalid
\'
methodBody
\'
:
$methodBody
'
);
}
printTrace
(
'reloadMethod not yet supported, falling back to hot reload'
);
try
{
await
reloadSources
(
isolateId
);
return
<
String
,
String
>{
'type'
:
'Success'
};
}
on
rpc
.
RpcException
{
rethrow
;
}
catch
(
e
,
st
)
{
throw
rpc
.
RpcException
(
rpc_error_code
.
SERVER_ERROR
,
'Error during Sources Reload:
$e
\n
$st
'
);
}
});
_peer
.
sendNotification
(
'registerService'
,
<
String
,
String
>{
'service'
:
'reloadMethod'
,
'alias'
:
'Flutter Tools'
,
});
}
if
(
restart
!=
null
)
{
...
...
packages/flutter_tools/test/general.shard/vmservice_test.dart
View file @
331d19ff
...
...
@@ -47,7 +47,7 @@ class MockPeer implements rpc.Peer {
@override
void
registerMethod
(
String
name
,
Function
callback
)
{
// this does get called
registeredMethods
.
add
(
name
);
}
@override
...
...
@@ -57,6 +57,7 @@ class MockPeer implements rpc.Peer {
}
Map
<
String
,
List
<
dynamic
>>
sentNotifications
=
<
String
,
List
<
dynamic
>>{};
List
<
String
>
registeredMethods
=
<
String
>[];
bool
isolatesEnabled
=
false
;
...
...
@@ -263,5 +264,18 @@ void main() {
Logger:
()
=>
StdoutLogger
(),
Stdio:
()
=>
mockStdio
,
});
testUsingContext
(
'registers hot UI method'
,
()
{
FakeAsync
().
run
((
FakeAsync
time
)
{
final
MockPeer
mockPeer
=
MockPeer
();
Future
<
void
>
reloadSources
(
String
isolateId
,
{
bool
pause
,
bool
force
})
async
{}
VMService
(
mockPeer
,
null
,
null
,
reloadSources
,
null
,
null
);
expect
(
mockPeer
.
registeredMethods
,
contains
(
'reloadMethod'
));
});
},
overrides:
<
Type
,
Generator
>{
Logger:
()
=>
StdoutLogger
(),
Stdio:
()
=>
mockStdio
,
});
});
}
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