Hi,On Sun, Feb 22, 2015 at 2:51 PM, SemanticBeeng . <semanticbeen...@gmail.com> wrote:Hi,1. I expose a TypeScript API (not JS) since the rest of the client code is TypeScript.That is irrelevant. You could have type parameters in TS and not in Scala.js, or vice versa, it would still work. Type parameters are only compile-time constructs, and disappear at runtime both with TS and Scala.js. Ultimately, the level at which TS and Scala.js communicate is the untyped JS.
2. "they are all supposed to be implemented in js."Hmm... what is the underlying reason for forcing this?I can see situations where ScalaJS apis exposed to JavaScript would want to return native JS objects but also mix-in other stuff from the ScalaJS side of the API.Is there a way to do this "mix-in" today better than my attempt?Any idea why it throws the error in the PromiseT constructor? If it did not then I could do the "mixing" from the ScalaJS side...I understand ScalaJS is meant to change the world of JS development but practically they will coexist.So maybe we should consider and provide some attention to this co-habitation?This is a fundamental limitation of Scala.js, as it currently stands. It is impossible to write a Scala.js class that extends/implements a JS type, because that extension causes said class to be a facade type itself. You can write Scala.js classes that export members, so that they (implicitly) comply with a JS interface. Then you can soundly cast your Scala.js class to the JS interface. But the compiler will not be able to help you.
4. Is there anything special or better to do with the execution context to make this combine promises work?I need to have this working from both real browser in prod but also native jasmine tests in PhantomJS.JQueryDeferred don't use execution contexts (necessarily), so no.
5. So should I add type params to https://github.com/scala-js/scala-js-jquery?Is it as simple as adding the type params?Yes, it is as simple as that. As I said, type parameters disappear at runtime.Cheers,Sébastien
Hi,I am looking to use ScalaJS to develop a business API called from a web application using Durandal and Knockout. The command layer calling the API will use promises/futures to communicate with the rest of the application.(more elaborate architectural description at the end to qualify questions below)So am trying to determine what is the best way to write this layer driven by "executable specifications".Found some references to ScalaJS support for async/promises but cannot quite tell which way to go.Below I ask some questions to better understand the plans for ScalaJS, utest and seek some recommendations.1. "The Jasmine test framework is not a good testing framework for Scala.js code, and is being removed in 0.6.x."Q: Where can I learn more about this and understand why Jasmine is bad for ScalaJS testing?JavaScript has impressive support for testing async code with promises: chai as promised, sinon.js, jasmine, mocha, etcSee more https://www.evernote.com/shard/s175/sh/ce94f122-efd2-41ee-93b2-429a489278ba/3c4557222348385aWhat does "bad" mean in terms of one being able to use this existing support?-------------------------------------------------------2. utest seems to support async testsReferencesQ: Does utest mean to provide full support for promises?Would one be able to use native JavaScript promise support to test JSExported shared APIs?From utests?From other kinds of tests?Or does "bad" in the above definition means that this is not a good idea?-------------------------------------------------------3. ScalaJS has support for scala Futures (scala.concurrent.Future)ReferencesQ: Does utest mean to support testing such APs?-------------------------------------------------------4. Autowire also uses Futures.Q: Does utest support testing such APIs? Any examples handy?FinallyQ: Can you please suggest some material to better understand how to BDD this ScalaJS based command layer that specifies the semantics of the shared business API given that it needs to be specified with "promises" (see [1])?=======(context for questions)The overall architecture uses CQRS and the calls to this business API will be using some form of command pattern.At this level it is customary to use "promises".Durandal and the rest of the application can use Q.JS (https://github.com/kriskowal/q) because they are a more standard implementation (https://blog.domenic.me/youre-missing-the-point-of-promises/).I could write this whole command layer in ScalaJS or in TypeScript and call JSExported methods from the business API.Regardless, I need this command layer to return Q.js promises to the rest of the application. [1]To implement this layer I am considering using Autowire but Play! makes much of it unnecessary.Thinking to reuse the shared API to wrap the JavaScript routes generated by Play! instead.This is supposed to provide even better typesafety than AutoWire because the Ajax calls itself will no longer be handcrafted like with AutoWire.(end of context)
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-js/024aec1a-61b2-48e7-8399-f060397525e0%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "Scala.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-js+u...@googlegroups.com.
@JSName("L.Popup")
class Popup(options: js.Object = null) extends Layer {
def openOn(map: MapBoxMap): Popup = js.native
def setLatLng(latlng: js.Array[Double]): Popup = js.native
def setContent(content: String): Popup = js.native
//
protected var _map: MapBoxMap = js.native
@JSNoExport
def hasMap(): Boolean = if (_map == null) false else true
}
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-js/CAORbNRqNvSuE_6ktqXHHyQc5qScxByvTH%3DM-6m0wG1DJKuqWcA%40mail.gmail.com.
Awesome, I can see this is a great thing to know about. Thanks for the logic tip, though I think the JS logic is proving to be a more serious barrier. In the API source they do things like:
if (this._map) ....