Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
blockly > fieldRegistry > zarejestruj się
Funkcja FieldRegistry.register()
Rejestruje typ pola. Pole Registry.fromJson korzysta z tego rejestru, aby znaleźć odpowiedni typ pola.
Podpis:
export declare function register(type: string, fieldClass: RegistrableField): void;
Parametry
Parametr |
Typ |
Opis |
typ |
ciąg znaków |
Nazwa typu pola używana w definicji JSON. |
fieldClass |
RegistrableField |
Klasa pola zawierająca funkcję fromJson, która może utworzyć wystąpienie pola. |
Zwroty:
nieważne
Wyjątki
{Błąd}, jeśli nazwa typu jest pusta, pole jest już zarejestrowane lub pole FieldClass nie jest obiektem zawierającym funkcję fromJson.
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: 2025-07-25 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-25 UTC."],[],["The `fieldRegistry.register()` function registers a field type for use with `fieldRegistry.fromJson`. It takes two parameters: `type` (a string representing the field type name) and `fieldClass` (a class with a `fromJson` function for constructing field instances). It returns void. The function throws an error if the type is empty, the field is already registered, or the class is invalid. It enables the system to find the appropriate field type during JSON parsing.\n"]]