I’m not entirely sure what you’re trying to accomplish, but what I think you need is:
In an initializer (i.e. assets/javascripts/discourse/initializers/initializer_example.js.es6):
import Composer from 'discourse/models/composer';
export default {
name: 'initializer_name'
initialize() {
// this adds your property to the attributes serialized to the server by the createPost method in the composer model
Composer.serializeOnCreate('your_property');
withPluginApi('0.8.12', api => {
api.modifyClass('model:composer', {
// set your_property here, or modify the composer controller and set it on the model there instead
})
})
}
}
In plugin.rb
after_initialize do
add_permitted_post_create_param('your_property')
DiscourseEvent.on(:post_created) do |post, opts, user|
# opts[:your_property] is available.
end
end
For an example, see my events, ratings or locations plugins.