1. Introduction
  2. Getting Started
  3. Using the CLI
  4. Coding Guide
  5. Assertions
  6. OOP
  7. Utils & Async
  8. Data Structures
  9. Universal Events
  10. Templating
  11. Indexed Tables
  12. Entities
  13. I18n
  14. Routing
  15. API Access
  16. Widgets
  17. Basic Widgets
  18. Asset Mgmt
  19. Session Mgmt
  20. Best Practices

Best Practices

No instantiation in .postponed & .amendPostponed

Make sure not to instantiate any classes inside a .postponed or .amendPostponed block that constructs a class. You may rely on language features, built-in types, and the class-building tools.

Instantiation within a .postponed block might lead to an infinite loop:

Result: Class "A" will never resolve, and you get a stack overflow error.

Instantiation within an .amendPostponed block might lead to unexpected behavior in surrogates:

Result: At the first user-initiated instantiation of "A" the surrogate might be applied last among the other amendments, in one of which instantiation will succeed & yield an instance of "A". Since "A" is memoized, from this on, it will always return the same instance for the same constructor arguments, regardless of the surrogate.

It's important that