Is it possible to let Kotlin to generate Emberjs-type classes?

I see some emberjs code:

https://github.com/discourse/discourse/blob/master/app/assets/javascripts/admin/controllers/admin_customize_controller.js

Discourse.AdminCustomizeController = Ember.Controller.extend({

   newCustomization: function() {

  var item = Discourse.SiteCustomization.create({name: Em.String.i18n("admin.customize.new_style")});

  this.get('content').pushObject(item);

  this.set('content.selectedItem', item);

  },

...

}

It has it's own "class" maker.

If I use Kotlin to define classes, the generated code is different. If I don't remember wrong, it should be:

Kotlin.createClass({});

Is it possible to configure Kotlin to generate emberjs(or other) classes code?

Such customization is not suported today. I'm not sure if it is feasible, but the idea sounds interesting.

I think you can just inherit from Ember.Controller.

Is there any demo which uses Kotlin to write emberjs code? I want to see if I can use Kotlin's class structrue to work with emberjs

I don't know about any demo with kotlin and ebmerjs. I just studied the sources of emberjs a little (after your question).

Alternative solutions: 1. You can declare own class and use it like:

``

val AdminCustomizeController = Ember.Controller.extend(MyController)
val adminController = AdminCustomizeController.create()

  1. You can use object:

``

val AdminCustomizeController = Ember.Controller.extend(object {
  fun foo() { … }

})


but AdminCustomizeController will not be a class for Kotlin compiler.

Thank you very much. I read the emberjs document today, and realized if Kotlin can't convert a Kotlin class to a JSON format, it will be many problems to work with Emberjs. For example, the properties:

class User {   var name:String   var age: Int   fun save() {} }

the "name" and "age" are properties, it wll have a getter and setter in the generated js code:

get_name() set_name(...)

So we have to write the getters in the view:

<script type="emberjs template"> Hello, {{user.get_name}}   // which is boring </script>

And may not work well with emberjs' properties.

So I think it’s best to wait for Kotlin provide better support for existing js frameworks.