-
-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow refreshBlocks()
to specify extension
#228
Conversation
Oh this'd be amazing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as intended. No issues with existing category's or extensions occurred during testing.
Testing extension
Af of now pressing any of these buttons would refresh ALL of the extensions updating the labels and count for every extension, on this pr it only does it for the individual extension you choose to refresh.
(function(Scratch) {
let countA = -1;
class extensionA {
getInfo() {
return {
id: '0znzwRefTest1',
name: 'Refresh Test (A)',
blocks: [{
blockType: Scratch.BlockType.LABEL,
text: `Extension refreshed ${++countA} times`,
}],
};
}
}
let countB = -1;
class extensionB {
getInfo() {
return {
id: '0znzwRefTest2',
name: 'Refresh Test (B)',
blocks: [{
blockType: Scratch.BlockType.LABEL,
text: `Extension refreshed ${++countB} times`,
}],
};
}
}
class extensionC {
getInfo() {
return {
id: '0znzwRefTest3',
name: 'Refresh Test (C)',
blocks: [{
blockType: Scratch.BlockType.LABEL,
text: `Extensions refreshed total ${(countA + countB)} times`,
}, {
blockType: Scratch.BlockType.BUTTON,
func: 'refreshALL',
text: 'Refresh all',
}, {
blockType: Scratch.BlockType.BUTTON,
func: 'refreshA',
text: 'Refresh (A)',
}, {
blockType: Scratch.BlockType.BUTTON,
func: 'refreshB',
text: 'Refresh (B)',
}, {
blockType: Scratch.BlockType.BUTTON,
func: 'refreshC',
text: 'Refresh (C)',
}],
};
}
refreshALL() {
Scratch.vm.extensionManager.refreshBlocks();
}
refreshA() {
Scratch.vm.extensionManager.refreshBlocks('0znzwRefTest1');
}
refreshB() {
Scratch.vm.extensionManager.refreshBlocks('0znzwRefTest2');
}
refreshC() {
Scratch.vm.extensionManager.refreshBlocks('0znzwRefTest3');
}
}
Scratch.extensions.register(new extensionA());
Scratch.extensions.register(new extensionB());
Scratch.extensions.register(new extensionC());
})(Scratch);
do you have any complaints about making unknown extensions be an error instead of silently ignoring it and refreshing all the extensions ? |
Nope, I think it should error as it clarifys things more |
Resolves
The base of dynamic blocks.
Proposed Changes
Added a optional parameter to
refreshBlocks
, allowing specify which extension to refresh.Reason for Changes
Performance considerations. This change was originally made by Gandi IDE, used for dynamic blocks (maybe), and I think we also need one.
Test Coverage
N/A. No tests for
refreshBlocks
found.