Feature: callback for field/model initialisation
See original GitHub issue[x] feature request
It would be nice to have an initialisation callback before fields are populated. For example:
-
In the Repeating Type, when model data exists, the FieldGroups are already populated, before the FieldArrayType implementation’s ngOnit runs. Having a callback would simplify the code. https://stackblitz.com/edit/angular-abr1eg?file=src/app/datatable.type.ts
-
In the Repeating Type to populate buttons.
-
In the Repeating Type to populate a first row in the model when no model data exists.
Some of this can be done before it is handed over to formly, but I think it also makes sense to have the option to have it as near to the library as possible.
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (17 by maintainers)
Top Results From Across the Web
Initialization Function - MATLAB & Simulink - MathWorks
Use the model InitFcn callback to initialize parameters and environment settings that are specific to the model, for example: Variables used in model...
Read more >best way to handle callback initialization and functions that ...
I think it woull be better to have the callback function initialized, so that the arrays are created, and then call the functions...
Read more >Initializing callbacks - IBM
All callbacks must be identified when you call the IMCreate subroutine. The IMCallback structure contains the address for each callback function.
Read more >CS 211 Lesson 30 GUI Components
Lesson Objectives: Be able to share values between callback functions. Be able to initialize GUI state. Be able to get and set GUI...
Read more >Documentation: 15: 51.1. Initialization Functions - PostgreSQL
To provide the required archive module callbacks and to indicate that the ... needs to be filled with the callback function pointers for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
good news, I figure-out that there is a way to create the field component instance too early so there a hope to have a such feature out of the box!
@aitboudad Great, your extension works as expected. It can solve to reduce complexities in the custom type’s code. Thanks a lot.
To use a field config implementation is not my favored one. To use a custom type the app component (by field config) has to provide code which needs to interact with the behaviour of the custom type or even provide the full code for the custom type’s intend.
To overcome this, before handing over the field config to formly an application can call a service which traverses through the field config, modifies the field config for a custom type and also provides the
populate
code.The idea of a custom type is to have an interface (by an as simple as possible field config) and a behaviour/semantics. It interacts closely with the formly library and shields of the implementation for it’s users (app component) (and even more the implementation of the formly library).
I was hoping more for a coded solution, extending a
populate
method in the derived custom type: TypeScript extending exampleAre there any drawbacks or implications using such a solution?
The field config implementation can be valuable for specific situations. Would be great to have an additional “coded” solution.
For the time being I will go the above described “using a service” path.