Repository navigation
[2.x] feat(core): introduce conditional frontend extenders - #5443
Conversation
|
Docs PR flarum/docs#706 ;) |
|
The new extender already uses There is one example to fix before merging: the Please replace that example with a condition that is available during extension boot and document the timing beside |
imorland
left a comment
There was a problem hiding this comment.
Please correct the when() JSDoc example before merging. Its predicate reads app.forum.attribute('acmeAdvancedMode'), but bootExtensions() evaluates it before app.boot() assigns app.forum and app.session. I reproduced the resulting TypeError; copying the advertised example prevents frontend startup.
Replace it with a condition available during extension boot and document that timing beside when(), consistent with the warning already in the linked docs PR. Please also exercise the callback with the supplied application before app.boot() in a test.
As noted in my earlier comment, please use 'acme-bar' in flarum.extensions in the description's detection example: an extension using only extend.ts need not register an initializer. The new extender already uses the correct registry check.
This gives parity to the addition in the backend flarum#5444
|
Thanks for the review and pointing out the (in retrospect) obvious flaw in the
@imorland May you please now have another look? |
Docs PR flarum/docs#706
Fixes #0000
When an extension only conditionally (e.g. only when another extension is enabled) wanted to use the frontend extenders like
Store()orModel()extensions have two awkwardly implement it. In Flarum 1 I've come across three patterns here on how it was solved before this PRApproach 1: Ternary in extend.ts:
Approach 2: Marking it as undefined in TS:
Approach 3: Avoid the conditional by creating a pivot extension
Approach three is to create a new dedicated extension which has hard dependencies on the integrating extensions.
Changes proposed in this pull request:
Implement new Conditional frontend extender to work similarly like the backend equivalent
Reviewers should focus on:
Backwards compatibility / general regression
Screenshot
(No-Op)
Before

After

Necessity
Confirmed
yarn testinjs/).composer test).Required changes: