I've created an extension using Quick start http://flarum.org/docs/extend/start/
When I am adding items to HeaderSecondary it happens 3 times and 3 sets of items are created during the boot. Last instance is on the page.
main.js:
import { extend } from 'flarum/extend';
import HeaderSecondary from 'flarum/components/HeaderSecondary';
window.a_iniTimes = 0;
window.a_instances = [];
app.initializers.add('axdr-test', () => {
extend(HeaderSecondary.prototype, 'items', function(items) {
a_iniTimes++;
items.add('test', <span>{ 'Test ' + a_iniTimes }</span>);
a_instances.push(items);
});
});
after loading:
a_iniTimes: 3
a_instances: {ItemList {..}, ItemList {..}, ItemList {..}}
bootstap.php:
<?php
use Flarum\Event\ConfigureClientView;
use Illuminate\Contracts\Events\Dispatcher;
return function (Dispatcher $events) {
$events->listen(ConfigureClientView::class, function (ConfigureClientView $event) {
if ($event->isForum()) {
$event->addAssets(__DIR__.'/js/forum/dist/extension.js');
$event->addBootstrapper('axdr/test/main');
}
});
};
composer.json:
{
"name": "axdr/test",
"type": "flarum-extension",
"description": "Test extension bug",
"license": "MIT",
"extra": {
"flarum-extension": {
"title": "axdr Test"
}
}
}
gulp.js:
var gulp = require('flarum-gulp');
gulp({
modules: {
'axdr/test': 'src/**/*.js'
}
});
What will you say?