Interfejsy w Blockly
W Blockly interfejsy opisują funkcje, które obiekt musi zaimplementować, aby zastąpić obiekt domyślny.
W celu wdrożenia interfejsu nie trzeba dziedziczyć z określonej klasy. Możesz wykonywać dowolne czynności, o ile podasz odpowiednie funkcje i będziesz przestrzegać wymogów opisanych w komentarzach. Częstym wzorcem wtyczek jest poszerzenie klasy domyślnej i zastąpienie tylko funkcji, które chcesz zmienić.
Aby umożliwić mechanizmowi sprawdzania typu zaimplementowania określonego interfejsu, dodaj adnotacje do klasy: @implements {InterfaceName}
.
Interfejsy Blockly są zdefiniowane w interfejsach podstawowych/interfejsach.
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2022-12-05 UTC.
[null,null,["Ostatnia aktualizacja: 2022-12-05 UTC."],[[["Blockly interfaces define functions objects must implement to replace default functionality."],["Implementing an interface doesn't require class inheritance, but adhering to function definitions and requirements is crucial."],["Annotate your class with `@implements {InterfaceName}` to indicate interface implementation to the type checker."],["While flexibility exists in implementation, extending the default class and overriding specific functions is a common pattern for plugins."],["Blockly's interface definitions are located in the `core/interfaces` directory of the repository."]]],[]]