I am making this Ensime package for Atom.io https://github.com/ensime/ensime-atom , and I was thinking about using scala.js instead of writing Coffeescript.
Atom is a web editor, script with js and node.js. A plugin / package defines its main entry point, pointing to a javascript object with a few specific ones.
I decided that I should start simple and try using scala.js, replacing the simplest coffeescript file that I have:
{View} = require 'atom-space-pen-views'
# View for the little status messages down there where messages from Ensime server can be shown
module.exports =
class StatusbarView extends View
@content: ->
@div class: 'ensime-status inline-block'
initialize: ->
serialize: ->
init: ->
@attach()
attach: =>
statusbar = document.querySelector('status-bar')
statusbar?.addLeftTile {item: this}
setText: (text) =>
@text("Ensime: #{text}").show()
destroy: ->
@detach()
As you can see, this exports the require.js module and is a class that also extends the class obtained with.
Soooo.
, Dynamic require dep, SO nodejs scala.js?
import js.Dynamic.{global => g}
import js.DynamicImplicits._
private[views] object SpacePen {
private val spacePenViews = require("atom-space-pen-views")
val view = spacePenViews.view
}
, asInstanceOf?
-, , node. :
https://github.com/rockymadden/scala-node/blob/master/main/src/main/coffeescript/example.coffee
? ? module module.exports = _some_scala_object_?
, js. , , :
https://groups.google.com/forum/#!topic/scala-js/l0gSOSiqubs
My code so far:
private[views] object SpacePen {
private val spacePenViews = js.Dynamic.global.require("atom-space-pen-views")
type View = spacePenViews.view
}
class StatusBarView extends SpacePen.View {
override def content =
super.div()
}
, Dynamic. .
!