These are chat archives for mithriljs/mithril.js

2nd
Apr 2016
Isiah Meadows
@isiahmeadows
Apr 02 2016 02:02
@lhorie Mind taking a look at #1005 (the PR for making vdom components as invalid)?
Leo Horie
@lhorie
Apr 02 2016 02:45
@isiahmeadows as a quick smoke test, I plugged it into my current project. but it blew up
Isiah Meadows
@isiahmeadows
Apr 02 2016 02:45
What went wrong, and where?
Leo Horie
@lhorie
Apr 02 2016 02:46
I'm gonna need to take a closer look to figure out what's going on. It's breaking in app space
Isiah Meadows
@isiahmeadows
Apr 02 2016 02:47
Okay. I knew it was a breaking change, so blow ups could go either way, app or library.
Leo Horie
@lhorie
Apr 02 2016 02:48
the error is that I pass a component A as an argument to another component B and accessing A's controller property is throwing an error
code is doing this:
if (role) {
    component = m.component(login.authorize, {component, role})
}
map[key] = m.component(layout, Object.assign({body: component}, options, routeOptions))
Leo Horie
@lhorie
Apr 02 2016 02:54
and then layout uses old-style component nesting (i.e. calling new component.controller from controller)
so refactoring this is going to have some bigger impacts because it would involve changing when nested components initialize
Isiah Meadows
@isiahmeadows
Apr 02 2016 02:59
@lhorie I updated the description of that PR. That should also help you with migrating.
Leo Horie
@lhorie
Apr 02 2016 03:00
hmm so maybe all it'll take is change it to use args.body.tag.controller instead of args.body.controller, when appropriate
Isiah Meadows
@isiahmeadows
Apr 02 2016 03:03
Just keep in mind that tag refers to the component itself, with no indirection.
Leo Horie
@lhorie
Apr 02 2016 03:05
yuppers
Isiah Meadows
@isiahmeadows
Apr 02 2016 03:13

Which means you have to manually construct it yourself. In case you're wondering, this is how I did it in the PR:

function construct(C, args) {
  switch (args.length) {
  case 0: return new C()
  case 1: return new C(args[0])
  case 2: return new C(args[0], args[1])
  case 3: return new C(args[0], args[1], args[2])
  case 4: return new C(args[0], args[1], args[2], args[3])
  default: return new (C.bind.apply(C, [undefined].concat(args)))()
  }
}

Long story short, I'm trying to help the engine out by not having to create an array and then call bind. It won't make much difference in smaller, simpler apps, but it can make a difference in larger and more dynamic apps.

Evgeniy Labutin
@LabEG
Apr 02 2016 06:28
@isiahmeadows ping, i have =)
Evgeniy Labutin
@LabEG
Apr 02 2016 06:35
i can not now find VirtualElement should fix the ambiguity, code frome last comment work fine
Mihai Cazacu
@cazacugmihai
Apr 02 2016 08:41
Hi, guys!
I have some performance problems with my app
(I'm using mithril)
I tried to add some timers to see where the problem is
but it seems that the "m.endComputation()" takes the most of the time
Arthur Clemens
@ArthurClemens
Apr 02 2016 08:44
@cazacugmihai Do you have any code to show?
Barney Carroll
@barneycarroll
Apr 02 2016 08:44
End computation triggers a redraw.
Mihai Cazacu
@cazacugmihai
Apr 02 2016 08:45
the application can be found here:
Barney Carroll
@barneycarroll
Apr 02 2016 08:45
Drawing is highly likely to be the most resource intensive operation for a Mithril application.
Mihai Cazacu
@cazacugmihai
Apr 02 2016 08:45
the source code can be located at Developer tools -> Sources -> webpack://
(the filtering is not accurate - is just a mock. the application is not connected to the backend right now. I just wanted to trigger a refresh in order to update the apartment's list)
(the code is written in coffescript but you'll see there the generated js)
Mihai Cazacu
@cazacugmihai
Apr 02 2016 08:51
the previous version of the app was written in angular and the behavior was a good one (~ 40 ms to render all page) but, because the angular 1.* was discontinued, I chose to rewrite it with mithril
I'm sure that there are a lot of issues with the implementation (I'm not a frontend expert) :)
It is very disappointing because the backend returns the result in ~ 10 ms and the rendering takes ~ 500ms
(and I know that it is my fault... I'm sure that mithril is very well designed/written)
Arthur Clemens
@ArthurClemens
Apr 02 2016 08:57
I can’t see the source code
ok, I see the coffee script. Not familiar.
Mihai Cazacu
@cazacugmihai
Apr 02 2016 08:58
@ArthurClemens : it is not showed in Developer Tools -> Sources -> webpack:// ?
Arthur Clemens
@ArthurClemens
Apr 02 2016 08:58
no
using Safari
Mihai Cazacu
@cazacugmihai
Apr 02 2016 08:58
I'm on Google Chrome
let me check on OSX
right now I'm using Ubuntu
Arthur Clemens
@ArthurClemens
Apr 02 2016 08:59
I see compressed js
Mihai Cazacu
@cazacugmihai
Apr 02 2016 09:01
I can see it in OSX/Google Chrome
The start entry is: webpack:// -> . -> index.coffee
Arthur Clemens
@ArthurClemens
Apr 02 2016 09:02
I see it
Mihai Cazacu
@cazacugmihai
Apr 02 2016 09:02
then the ". -> routes -> apartment -> buy -> index.coffee" is loaded
more precisely: index.coffee?../~/coffee-loader
Arthur Clemens
@ArthurClemens
Apr 02 2016 09:04
in which part is most time spent?
Mihai Cazacu
@cazacugmihai
Apr 02 2016 09:05
please check the console
there is some outputs with the elapsed times
the most part is spent in rendering the results
the apartment list
Arthur Clemens
@ArthurClemens
Apr 02 2016 09:06
you are innate familiar with your own code. which script?
Mihai Cazacu
@cazacugmihai
Apr 02 2016 09:06
1 sec
routes -> apartment -> buy -> results-panel -> results-panel.coffee
one strange thing: if I remove all the code from the "view" method on that file, and keep only the "console.time('render-results');", the rendering of that component takes ~ 40 ms
Arthur Clemens
@ArthurClemens
Apr 02 2016 09:09
and if you replace m(Apartment ..) with m(‘div’)?
Mihai Cazacu
@cazacugmihai
Apr 02 2016 09:09
the same thing: ~ 40 ms
let me change it in order to see the output
Arthur Clemens
@ArthurClemens
Apr 02 2016 09:10
so it is in Apartment
Mihai Cazacu
@cazacugmihai
Apr 02 2016 09:13
I just changed the code
render-results: 85.749ms
without doing nothing
(you can see this drawing a shape on the map and watching the output in Console)
Arthur Clemens
@ArthurClemens
Apr 02 2016 09:17
here it is about 50ms
Mihai Cazacu
@cazacugmihai
Apr 02 2016 09:17
quite enough: for something that doesn't do something
Arthur Clemens
@ArthurClemens
Apr 02 2016 09:19
do you mean that it is still too much time?
Mihai Cazacu
@cazacugmihai
Apr 02 2016 09:20
for drawing results-panel? yes
if you want to see the code and also change something, please join to this Teamviewer meeting:
http://go.teamviewer.com/v11/m30299397
drawing the results-panel component: a simple div with nothing (because I removed the listing of the apartments and the pagination)
Mihai Cazacu
@cazacugmihai
Apr 02 2016 09:53
If anyone has 5-10 min in order to take a look over the code, please access http://go.teamviewer.com/v11/m30299397
thank you!
Hitesh Joshi
@hiteshjoshi
Apr 02 2016 10:12
Hey Guys, I have small problem with mithril promise I think.
I am using Google Plus one client.
and m.prop trigger from inside gapi (google plug promise) does not make two way data binding unless something else gets triggered. Eg I click on a button with an event etc
graphed is basically a port of m
possible reason for this?
Hitesh Joshi
@hiteshjoshi
Apr 02 2016 10:17
Login is my CTRL
Hitesh Joshi
@hiteshjoshi
Apr 02 2016 10:28
any suggestions?
Arthur Clemens
@ArthurClemens
Apr 02 2016 10:29
@hiteshjoshi I cannot make sense of your question
did you ask a question?
Hitesh Joshi
@hiteshjoshi
Apr 02 2016 10:33
A problem which I think is related to an external Promises.
Let me write in few lines. sec
my view
Login.view = function(ctrl){
    return !ctrl.googleTokens() ? Login.form(ctrl) : Login.dashboard(ctrl)
}
my controller
Login.controller = function(){
    var ctrl = {};

ctrl.GoogleClick = function(){

                        auth2
                        .signIn()
                        .then(function(googleUser){

                            ctrl.googleTokens = m.prop(googleUser);




                        },function(error){
                            console.log(error);
                        });
                    };
        return ctrl;
since view depends on ctrl.googleTokens
view should change as soon as user is logged in with Google
but ctrl.googleTokens wont update. I think thats because of the promise that comes with google auth client.
And my script needs to wait until that promise gets resolved?
Arthur Clemens
@ArthurClemens
Apr 02 2016 10:38
is that promise resolved and function(googleUser) called?
Hitesh Joshi
@hiteshjoshi
Apr 02 2016 10:38
Yes
It gets called. If I do console.log I get value of googleUser in console too
Arthur Clemens
@ArthurClemens
Apr 02 2016 10:38
you need to call m.redraw after setting ctrl.googleTokens
Hitesh Joshi
@hiteshjoshi
Apr 02 2016 10:39
ah! because the other Promise doenst resolve the view? Can you also help me underestand what this happened.
Arthur Clemens
@ArthurClemens
Apr 02 2016 10:40
there is no magic, you need to tell Mithril when a redraw is needed
Hitesh Joshi
@hiteshjoshi
Apr 02 2016 10:40
well I thought so.
But if I do this
                    setTimeout(function(){
                            ctrl.googleTokens = m.prop((new Date()).getTime());
                        },3000)
the view still gets reload without telling mithril to redraw
Arthur Clemens
@ArthurClemens
Apr 02 2016 10:43
if the view gets called it may be because of other interactions, f.i. clicks
Hitesh Joshi
@hiteshjoshi
Apr 02 2016 10:44
I am certain no other events were raised.
I think it is because of an external promise. But want to be sure.
Arthur Clemens
@ArthurClemens
Apr 02 2016 10:44
are you using m.request somewhere?
Hitesh Joshi
@hiteshjoshi
Apr 02 2016 10:45
Yes
Arthur Clemens
@ArthurClemens
Apr 02 2016 10:45
because that calls m.redraw
Hitesh Joshi
@hiteshjoshi
Apr 02 2016 10:45
oh!!!
I got it now.
Thanks Arthur
So its not promise related anyway.
Arthur Clemens
@ArthurClemens
Apr 02 2016 10:45
no
Hitesh Joshi
@hiteshjoshi
Apr 02 2016 10:46
thank you
Arthur Clemens
@ArthurClemens
Apr 02 2016 10:46
np
Barney Carroll
@barneycarroll
Apr 02 2016 10:54
@cazacugmihai people here often help each other by showing their code with private gists, it makes it easier for other people to see and help. That view / controller you have that takes too long to render — could you post it this way?
Mihai Cazacu
@cazacugmihai
Apr 02 2016 12:46
@barneycarroll : no, I can't. There are too many files
For me, the best way to get help is to find someone that wish to connect (via Teamviewer) to my machine and deal with the code
Maybe a 5-10 min session will be enough
The code is pretty clean/simple but there are too many files involved
Barney Carroll
@barneycarroll
Apr 02 2016 12:50
Oh well. Good luck!
Mihai Cazacu
@cazacugmihai
Apr 02 2016 12:51
:)
James Forbes
@JAForbes
Apr 02 2016 12:51
@cazacugmihai You can at least post the component that takes the most time in the profiler. It's highly likely we will find the issue.
Mihai Cazacu
@cazacugmihai
Apr 02 2016 12:52
@JAForbes : I don't know how I can find that component
There are some timers but the most of the time is spent in "m.endComputation()"
James Forbes
@JAForbes
Apr 02 2016 12:55
There are two views in the profiler. Bottom up, and top down.
You want to look at top down
That will show you the leaves of the call stack that take the most time, instead of the root of the call stack
endComputation is just the start of the road, the performance issue will be in your view most likely
m.endComputation = function () {
        if (pendingRequests > 1) {
            pendingRequests--
        } else {
            pendingRequests = 0
            m.redraw()
        }
    }
Mihai Cazacu
@cazacugmihai
Apr 02 2016 12:56
@barneycarroll: I cannot see the difference (from the person that wishes to give me some help) between putting the whole code in a gitlab and asking someone to connect to my machine where the environment is already there and the app is up an running.
James Forbes
@JAForbes
Apr 02 2016 12:58
Immediately you will see the functions that take a lot of time are yours
you can then post that function here, to a gist
Mihai Cazacu
@cazacugmihai
Apr 02 2016 12:58
@JAForbes: Thanks! I'll try that
James Forbes
@JAForbes
Apr 02 2016 12:58
and we'll be able to help
:+1:
Mihai Cazacu
@cazacugmihai
Apr 02 2016 12:58
I hope so :)
what is the meaning of "pendingRequests"?
is a mithril's variable?
from the mithril's source code:
m.endComputation = function () {
if (pendingRequests > 1) {
pendingRequests--
} else {
pendingRequests = 0
m.redraw()
}
}
James Forbes
@JAForbes
Apr 02 2016 13:02
The reason I posted that code was to underscore, that it isn't the problem.
Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:02
ah, I see
James Forbes
@JAForbes
Apr 02 2016 13:05

It is just an entry point into the redraw process. And all the redraw does is run your views, compares the output to the previous draw and then applies it to the DOM. If the redraw process takes longer its probably 1 of 2 things.

  1. Your view is doing some heavy calculations every frame, that could probably be pushed into the controller layer.
  2. Your view is massive and it just takes a long time to diff.

Its very likely to be 1. - because many people here work with big DOM trees with mithril without hitting performance issues.

The top down call stack in the profiler should point us to the problem function that is being called in the redraw
Arthur Clemens
@ArthurClemens
Apr 02 2016 13:06
if you are using start/endComputation in your code, you are perhaps relying on third party code to resolve
Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:10
@ArthurClemens : I'm using that methods to trigger an update (after a component changed its state - based on user interaction)
ex:
a radio button is checked, then:
onValueChanged: (e, value) ->
m.startComputation()
filter.value = value
filter.onValueChanged()
m.endComputation()
})
Arthur Clemens
@ArthurClemens
Apr 02 2016 13:11
that is unnecessary, you can replace that with m.redraw
if onValueChanged is triggered by a default event, you even don’t need m.redraw
James Forbes
@JAForbes
Apr 02 2016 13:12

@cazacugmihai could you wrap your code in backticks?

```
code goes here
```

it will make it easier for us to read
Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:12
@JAForbes : sure, I din't know how to format the code. Thank you!
James Forbes
@JAForbes
Apr 02 2016 13:13
pleasure
Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:14
@ArthurClemens : you have right (I didn't check it yet on my code): m.startComputation / m.endComputation are used in async functions
Arthur Clemens
@ArthurClemens
Apr 02 2016 13:14
you only need it when waiting for third party code to finish
so almost never
Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:15
right
I was afraid of:
quote: In contrast, m.redraw is "aggressive"
James Forbes
@JAForbes
Apr 02 2016 13:15

@cazacugmihai here's a few tips for async situations

  1. Start with a default value, render immediately after with m.redraw.
  2. Calling m.redraw in the same call stack multiple times will not actually redraw multiple times, it creates a pendingRequest, and will actually perform the diff when your app stops calling it
  3. If its a promise, its as easy as

       fetch('...')
        .then(m.redraw)
  4. start/stop computation is really only there for edge cases, and its best to use m.redraw if possible

Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:16
nice, I'll try ASAP
@JAForbes : yes, the code works also after I removed that m.startComputation / m.endComputation
Barney Carroll
@barneycarroll
Apr 02 2016 13:18
Excellent
Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:19
I will remove all that "m.startComputation / m.endComputation" from the code, excepting where the async calls are needed
thank you! :D
I hope that this will improve the performance
I'll come back with the results
there is another case:
James Forbes
@JAForbes
Apr 02 2016 13:20
good luck
Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:20
I'm using "slideUp" and "slideDown" animations
and, before calling one of these functions, I wrap the call into m.startComputation / m.endComputation
something like this:
m.startComputation()
someDiv.stop().slideUp('fast', m.endComputation)
James Forbes
@JAForbes
Apr 02 2016 13:22
is this an exit animation, before someDiv is removed from the dom?
sorry, I should let you state the problem first
Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:23
the div is not removed
it is only hidden
James Forbes
@JAForbes
Apr 02 2016 13:24
and you are wondering whether to keep the computation calls?
Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:24
yes
I recall that I tried first without start/endComputation but it didn't work
James Forbes
@JAForbes
Apr 02 2016 13:25
Other more experienced devs might correct me, but from my point of view, there is no need to redraw at all. So just
someDiv.stop().slideUp('fast')
Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:25
I wanted that the some computation to be made after the div is hidden (slideUp)
James Forbes
@JAForbes
Apr 02 2016 13:25
Because you are interacting with the DOM directly, mithril doesn't know about it. But in this case, that doesn't matter.
is the computation part of your view function? if it is, it probably shouldn't be
Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:26
I'll try again without that calls (start/endComputation)
no, it is on controller
James Forbes
@JAForbes
Apr 02 2016 13:27
put m.redraw inside your controller function e.g.
function somethingSlow(){
   //do stuff
   m.redraw()
}

somDiv.stop().slideUp('fast', somethingSlow)
that way, other view calls don't slow down because of this 1 time computation
Mihai Cazacu
@cazacugmihai
Apr 02 2016 13:32
@JAForbes : ok
Mihai Cazacu
@cazacugmihai
Apr 02 2016 14:05
I was somhow happy about removing that start/endComputation but, in the most of the cases, I need them
even:
onValueChanged: (e, value) ->
    m.startComputation()
    filter.value = value
    filter.onValueChanged()
    m.endComputation()
the reason:
after a filter is changed, I want the filter title to be update instantaneous
removing those start/endComputation the update is made too late (in ~ 500 ms or 1s)
maybe there is a delay in mithril code (for optimization)
a filter is composed of two parts:
a header (title + value)
Mihai Cazacu
@cazacugmihai
Apr 02 2016 14:10
an body (the are where user can check some options)
when an option (an independet component) is checked, the parent (filter) must be alerted
in order to update some child (the header)
Arthur Clemens
@ArthurClemens
Apr 02 2016 14:13
I believe m.redraw is in the 4ms range
James Forbes
@JAForbes
Apr 02 2016 14:13
@cazacugmihai What operating system are you on? Maybe its a bug in Windows? What kind of monitor do you have, maybe its the refresh rate? :)
The 500ms delay is not caused by mithril, is what I'm trying to say.
Mihai Cazacu
@cazacugmihai
Apr 02 2016 14:16
I'm using Ubuntu
refresh rate: 60Hz
(the laptop has a very good configuration)
also I'm using the latest OS version. I'm sure that there is not an hardware issue
If I'm using start/endComputation, the filer's value is updated instantaneously
Mihai Cazacu
@cazacugmihai
Apr 02 2016 14:23
well, not instantaneously but fast enough that it is not disturbing
Mihai Cazacu
@cazacugmihai
Apr 02 2016 14:58
so, back to my original kindly question: if there is someone that wishes to connect to my PC (using Teamviewer) and check the code, please contact me. I know that everybody has something better to do, so we can discuss a way to reward that spent time. Thanks!
James Forbes
@JAForbes
Apr 02 2016 15:25

@cazacugmihai I don't think anyone will take you up on your offer of Teamviewer, but its nice you are offering compensation. So good luck!

In any case, I still recommend looking at the top down view in the profiler, find the slow function in your code. Debug it, and replace all your start/end computation calls with m.redraw - doing that is a very good start.

The reason I brought up windows, and your screen refresh rate, was to point out how unlikely it is that mithril is the thing causing your problem. Just as unlikely as Ubuntu, or a full moon causing performance issues in your web app.
Mithril is not the reason your code is slow. If you can accept that, you will solve the problem more readily.

When you see that mithril takes 500ms to redraw, you have to see that isn't mithril being slow, that is your view functions being slow. Yes, the redraw may be slow, but its not the redraw process.

If you identify the slow code, paste it into a gist, and we will happily help you walk through it.
Mihai Cazacu
@cazacugmihai
Apr 02 2016 15:32
@JAForbes thanks for your time!
James Forbes
@JAForbes
Apr 02 2016 15:43
:)
Mihai Cazacu
@cazacugmihai
Apr 02 2016 15:44
I'm trying to use the Timeline feature from Chrome...
It is a kind of SF for me :D
James Forbes
@JAForbes
Apr 02 2016 15:48
SF?
Mihai Cazacu
@cazacugmihai
Apr 02 2016 15:48
science fiction
James Forbes
@JAForbes
Apr 02 2016 15:48
haha
I read it as San Francisco
Mihai Cazacu
@cazacugmihai
Apr 02 2016 15:48
:D
James Forbes
@JAForbes
Apr 02 2016 15:54

You really need to go to the profiler though, record while you perform the slow action. Stop recording, then where it says "Heavy (Bottom Up)" click that and then click

"Tree (Top Down)"

There will be 3 columns.

On the left is self this is how long on average was spent in that function alone

The 2nd column is total, this is how long was spent in that function throughout the recording.

The 3rd column is the function names.

Few things to note...

Just because a function has a high total, doesn't mean that's bad. It could just be an important function. But this top down will help you find which functions are either popular or slow.

redraw should be in the 3rd column. Unfold it, then keep unfolding until you find code that is yours. There will be a function in there that is taking a lot of time, that doesn't live in the mithril codebase.

You can then click on the source link on the right. And post it here.

Mihai Cazacu
@cazacugmihai
Apr 02 2016 15:56
What option should I select in Profiler? The default one: "Collect JavaScript CPU Profile"?
James Forbes
@JAForbes
Apr 02 2016 15:57
yep
Mihai Cazacu
@cazacugmihai
Apr 02 2016 15:57
ok, thanks!
James Forbes
@JAForbes
Apr 02 2016 15:57
its a good starting point
it helps us see if its an algorithmic issue
which it most likely is
Mihai Cazacu
@cazacugmihai
Apr 02 2016 15:57
aha
James Forbes
@JAForbes
Apr 02 2016 15:57
:)
but if its a memory issue, we'll have a good hint by how much time was spent garbage collecting
and then you could do a heap profile instead
but its not going to be a memory issue
the tools are great
Mihai Cazacu
@cazacugmihai
Apr 02 2016 15:58
I hope so
(It is the first time when I use them)
James Forbes
@JAForbes
Apr 02 2016 15:59
you'll do great
Mihai Cazacu
@cazacugmihai
Apr 02 2016 15:59
Until now I relied on console.time/timeEnd
James Forbes
@JAForbes
Apr 02 2016 15:59
well that's actually a good tool too
Mihai Cazacu
@cazacugmihai
Apr 02 2016 16:00
ok... let me try
James Forbes
@JAForbes
Apr 02 2016 16:00
what's so great about time and timeEnd is that it will label your graphs in the timeline
which is then searchable
so it really helps if you did a long recording
Isiah Meadows
@isiahmeadows
Apr 02 2016 16:01
@LabEG I hadn't gotten around to fixing that yet. Sorry. :frowning:
Evgeniy Labutin
@LabEG
Apr 02 2016 16:01
ok =)
Isiah Meadows
@isiahmeadows
Apr 02 2016 16:13
And, I've made a few updates.
@LabEG
To that branch.
James Forbes
@JAForbes
Apr 02 2016 16:14
@cazacugmihai I need to sleep, good luck, I'm sure others will help you out when you find the culprit.
Mihai Cazacu
@cazacugmihai
Apr 02 2016 16:15
@JAForbes : Thank you for your help! It was a valuable one. Sleep well! :)
James Forbes
@JAForbes
Apr 02 2016 16:16
Glad to hear it! Have fun diving into chrome's innards
Arthur Clemens
@ArthurClemens
Apr 02 2016 16:21
FYI: I’ve updated mithril-template-converter with indentation, HTML entity support, and loading of examples in the input area: http://arthurclemens.github.io/mithril-template-converter/index.html
Evgeniy Labutin
@LabEG
Apr 02 2016 16:30

@isiahmeadows
without this

(selector: string,
         ...children: Children[]): VirtualElement;

he think that this

m(
        'div.title',
        preset.title
)
`

is component and show error
: Error TS2345: Argument of type 'string' is not assignable to parameter of type 'Component<{}>'.

all m('div', 'text') constructions
Isiah Meadows
@isiahmeadows
Apr 02 2016 16:32
I think it's because any object is assignable to Attributes. I pushed an overload that should hopefully help the compiler out.
Attributes has a {[key: string]: value} property. That may be what's causing it.
Evgeniy Labutin
@LabEG
Apr 02 2016 16:33
yep
Evgeniy Labutin
@LabEG
Apr 02 2016 16:40
Can't concoct anything. Maybe now just restore, and later thinking about it?
Isiah Meadows
@isiahmeadows
Apr 02 2016 16:43
I restored the overload already.
Evgeniy Labutin
@LabEG
Apr 02 2016 16:43
ok
Evgeniy Labutin
@LabEG
Apr 02 2016 16:49
@isiahmeadows now all fine =)
Isiah Meadows
@isiahmeadows
Apr 02 2016 17:06
@LabEG Now to the Promises. I'm not addressing #914 until it's actually resolved in core. The TypeScript definition will be technically incorrect until then, but unless you're compiling to ES6, it won't be noticeable in practice.
Evgeniy Labutin
@LabEG
Apr 02 2016 17:14
@isiahmeadows i don't use mithril promise, but can see where is bug
and make tests
Isiah Meadows
@isiahmeadows
Apr 02 2016 17:15
Go ahead and point it out on there. It'll be easier to figure out what exactly you're pointing out. :smile:
Evgeniy Labutin
@LabEG
Apr 02 2016 17:17
ok =)
Isiah Meadows
@isiahmeadows
Apr 02 2016 17:21
@LabEG To clarify, I meant on #997.
Evgeniy Labutin
@LabEG
Apr 02 2016 17:52
@isiahmeadows Promise does not throw the error on my simple test, but I think that typing for him can be simpler.
Isiah Meadows
@isiahmeadows
Apr 02 2016 17:55
I dropped the PromiseProperty, which almost duplicated Promise. I just now removed some redundant prototypes as well.
As for the current diff, it actually simplifies a lot.
* s/prototypes/method signatures/g
Evgeniy Labutin
@LabEG
Apr 02 2016 18:00
yes, I've seen, let's leave yet, and later if anyone will be need then correct him =)
Evgeniy Labutin
@LabEG
Apr 02 2016 18:07
@isiahmeadows make merge to next all typings branch and tomorrow i will be make complex test latest mithrill with latest typing
997 and new
Isiah Meadows
@isiahmeadows
Apr 02 2016 18:07
What do you mean by new?
Evgeniy Labutin
@LabEG
Apr 02 2016 18:12
does not remember =)
then only 997 =)
Where it was breaking changes of contructor controller
Stephan Hoyer
@StephanHoyer
Apr 02 2016 18:51
@ArthurClemens nice!
Isiah Meadows
@isiahmeadows
Apr 02 2016 19:09
@LabEG Actually, I pulled the #914 (controller issues) definition fix because the jury is still out on that one, and like I said, unless you're compiling to ES6 (which you're likely not), it shouldn't be a problem.
That issue was the one regarding callable/constructible. The current state of discussion is mostly found in #994, my proposed solution. Note that this solution isn't unanimously agreed upon, and there's not even enough support yet to make a PR worthwhile for it.
Isiah Meadows
@isiahmeadows
Apr 02 2016 19:31
@LabEG #997 in its current state is merged now.
Isiah Meadows
@isiahmeadows
Apr 02 2016 20:47

@/all PSA for TypeScript users: #997 makes some very significant changes to the TypeScript definitions, simplifying and correcting them. Note that some of the changes require TypeScript 1.8 to work, most notably the use of string literal types.

For a more comprehensive overview of all the relevant changes made in this PR, please consult this comment.

Isiah Meadows
@isiahmeadows
Apr 02 2016 21:13
@lhorie How's #1005 looking so far?