Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • May 01 07:29
    back2dos synchronize #91
  • May 01 07:29

    back2dos on v1

    Add key value iterator to Child… (compare)

  • Apr 28 23:26
    dependabot[bot] labeled #30
  • Apr 28 23:26
    dependabot[bot] opened #30
  • Apr 28 23:26

    dependabot[bot] on npm_and_yarn

    Bump cross-fetch from 3.1.4 to … (compare)

  • Apr 28 21:11
    dependabot[bot] labeled #29
  • Apr 28 21:11
    dependabot[bot] opened #29
  • Apr 28 21:11

    dependabot[bot] on npm_and_yarn

    Bump async from 2.6.3 to 2.6.4 … (compare)

  • Apr 26 13:20
    darmie opened #94
  • Apr 10 17:59
    dependabot[bot] labeled #28
  • Apr 10 17:59
    dependabot[bot] opened #28
  • Apr 10 17:59

    dependabot[bot] on npm_and_yarn

    Bump minimist from 1.2.5 to 1.2… (compare)

  • Apr 02 18:09
    back2dos synchronize #91
  • Apr 02 18:09

    back2dos on v1

    Slightly better Attribute imple… (compare)

  • Mar 31 09:19
    kevinresol commented #59
  • Mar 31 09:18
    kevinresol commented #59
  • Mar 29 16:28
    back2dos opened #82
  • Mar 26 17:48
    dependabot[bot] labeled #23
  • Mar 26 17:48
    dependabot[bot] opened #23
  • Mar 26 17:48

    dependabot[bot] on npm_and_yarn

    Bump minimist from 1.2.5 to 1.2… (compare)

Kevin Leung
@kevinresol
Currently I have some tests for Models
and I want to make some UI tests using automation engines such as cypress.io
grepsuzette
@grepsuzette

So, I discovered puppeteer with lix run travix run js, this seems like what I was dreaming of :).

Now however I am getting ReferenceError: require is not defined at this line var coconut_react_internal_NativeComponent = require("react").Component;. Is there anything I can do? (for now, all I see is ask the question and go grab some beers)

grepsuzette
@grepsuzette
think this is the answer https://github.com/kLabz/haxe-react/blob/next/README.md#react-js-dependency (second compile with browserify or download from CDN). With travix though I don't know how
grepsuzette
@grepsuzette
If someone knows, please help! For now will sleep...
Juraj Kirchheim
@back2dos
uhm, I suppose the easiest way to deal with it is by bundling a CDN version of react with the build using https://github.com/back2dos/embed-js
(and setting -D react_global)
grepsuzette
@grepsuzette
Yay!! it works, thanks a lot!
grepsuzette
@grepsuzette
Applying idea of https://github.com/MVCoconut/coconut.data#injecting-services (modularize models to reduce dependencies).
Imagine a Model with @:constant var server : { function foo():Promise<String>; }.
Called from travix or for unit test, this Model will be given a dummy function like ()->"Foo".
But when compiled in an App, the Model would receive a tink_web proxy, like tink.web.proxy.Remote<Something>.
While this Something has a function foo, it won't unite (because there seem to be subtleties in the macro), giving this error: tink.web.proxy.Remote1 should be { foo : () -> tink.Promise<String> }.
Any idea? It is not a big problem in itself, but I am trying to develop good habits and this is why I ask for the best way
Kevin Leung
@kevinresol
you cant really create a remote with method returning Promise<String>
because String is converted to IncomingResponse on client side
grepsuzette
@grepsuzette
yes it was an example
Kevin Leung
@kevinresol
what happens if you put {foo: remote.foo}?
or even {foo: () -> remote.foo()}?
grepsuzette
@grepsuzette
\o/ (both work, thanks!)
grepsuzette
@grepsuzette

Better I type here than add garbage to MVCoconut/coconut.ui#92. So after updating +tink state (1.0.0-beta.3) and core (2.0.2), the JS fails at the last line with process:

    var wasUpdating = tink_state_Observable.isUpdating;
        tink_state_Observable.isUpdating = true;
        return tink_core_TypedError.tryFinally(function() {
            var hrtime = process.hrtime();

process is not defined

that may be js.Node.process but why is it undefined?
grepsuzette
@grepsuzette
:eyes: forget it. if I try to run it from a browser of course process is not defined...
Juraj Kirchheim
@back2dos
but shouldn't you get an exception instead of nothing?
Kevin Leung
@kevinresol
A question on patterns for async data source, which one is better?
class OverviewPage extends View {

    @:attr var data1:Promised<Data1>;

    @:attr var getData2:()->Promise<Data2>;
    @:loaded var data2:Data2 = getData2();

    @:attr var getData3:()->Promise<Data3>;

    @:attr var data4:Model4;


    function render() '
        <Widget1 data=${data1} />
        <Widget2 data=${data2} />
        <Widget3 getData=${getData3} />
        <Widget4 data=${data4} />
    ';
}

class Model4 implements Model {
    @:attr var getData:()->Promise<Data4>;
    @:loaded var data:Data4 = getData();
}
Juraj Kirchheim
@back2dos
phew ... it depends ^^
Kevin Leung
@kevinresol
yeah I am using each of them all over the place....
serjek
@serjek
attr is allowed in Model?
Kevin Leung
@kevinresol
should be @:constant
but you get the idea
serjek
@serjek
yeah. so I tend to use 1 and 4, because I believe services should belong to model
Juraj Kirchheim
@back2dos
myeah, ideally your application should be able to run without a view
although to create a model only for the sake of having one piece of loaded data is a bit overkill ^^
Kevin Leung
@kevinresol
yeah I think my app can run without a view. but my views can't run without the app data.
Juraj Kirchheim
@back2dos
:D
Kevin Leung
@kevinresol
mainly because my models store a reference to a tink_web remote instance
now whenever I wanted to test my view isolated I need to prepare a remote
I think I prefer #1 in most of the cases but it is not very ergonomic when it comes to optional attribute
and I even proposed to add @:promised var data:Data1 as a shorthand of #1
Juraj Kirchheim
@back2dos
yeah ... ideally the model wouldn't really depend on a remote proxy
one option is to make a @:genericBuild class Like<T> {} that takes an interface/class and returns a structure corresponding to it
then you can go @:constant var services:Like<Remote<Api>> and you can stick in a remote, but during tests just an anonymous object that returns what you want it to
or you can have an interface for your model and then one implementation is build on remotes and another is just a mock that is easy to set up for tests
grepsuzette
@grepsuzette
I have ModalWindow extends View.
And in the App class, static function modal(modal:ModalWindow) { ... ; Renderer.mount( div, modal); }.
But the second argument of Rendered.mount has to be RenderedResult; so what is the recommended way to render a view? (render() is private, so that's not it right?)
grepsuzette
@grepsuzette
to answer my own question, for now I can modal(view:RenderResult) and then modal(<ModalWindow>..</ModalWindow>), should be good enough
Juraj Kirchheim
@back2dos
yep
Thomas J. Webb
@thomasjwebb
How feasible is it to use something like antd (https://ant.design) with coconut or just haxe-react? I'm having issues making haxe externs for antd's typescript but also wondering if there will be other snags I'd hit trying to use its components, preferably in a coconut-ui-based app.
Thomas J. Webb
@thomasjwebb
Answering my own question - not very
grepsuzette
@grepsuzette
class Team implements coconut.data.Model {
    @:editable var color : String;
}

class World implements coconut.data.Model  {
    @:editable var colors : List<String> = List.fromArray(['red', 'green']);
    @:computed var teams : List<Team> = colors.map( k -> new Team({color:k}) );
}
In this example, any time colors will be edited, I think the objects in teams will be entirely rebuit. But when each team is complex enough, with @:loaded and what not, it is not very good. I am trying to find a way for them to persist but keeping @:computed if possible. Or is there a better approach
Kevin Leung
@kevinresol
Depending on your need you may use some cache (e.g. a StringMap) to store the teams?
grepsuzette
@grepsuzette
ah yes, k -> if (in cache) else put in the cache. Yes thanks :)
Juraj Kirchheim
@back2dos
in @:computed you can also access the last value as $last which is an Option (because on the first computation it is None) ... it's a little less straightforward, but since the previous value is discarded after the computation, you need not worry about keeping too many stale values around
grepsuzette
@grepsuzette
class V extends View {                                                  
    @:state var num : Int = 0;                                          
    @:attr var setVal : Int->Void = (n:Int) -> num = n;                                                                        
    function render() <>                                               
        <input type="number" defaultValue={Std.string(num)} />          
        <button onclick={setVal(24)} value="24" />                  
        <button onclick={setVal(37)} value="37" />                        
    </>;                                                                
}
this renders _0__ [ 24 ] [ 37 ], however on the react-dom backend (only), clicking the buttons 24 and 37 won't change the input. I think this is a problem that can not be fixed for now and instead it has to be worked around, but does anybody understands what's wrong in the first place?