These are chat archives for mithriljs/mithril.js

29th
Sep 2015
Isiah Meadows
@isiahmeadows
Sep 29 2015 02:25
@mrtracy There have been only three changes to the TypeScript definition file since master: a whitespace-only change - lhorie/mithril.js@d4848c0, documentation + increased type verification - lhorie/mithril.js@51f5941, and added documentation/definition for the m(component) shorthand for m.component(component) - lhorie/mithril.js@ed3f3f0. And if the bug is in master (but not next), file a PR against master. Bug fix backports are likely to be accepted as long as it's not breaking anything. Also note that master points to 0.1.34, while the npm package points to 0.2.0.
Arthur Clemens
@ArthurClemens
Sep 29 2015 12:27
@jpablom I have fixed the jsbin: http://jsbin.com/riqixu/edit?js,console,output
you have 2 options: in the config either call m.redraw inside a setTimeout (but this gives a redraw flicker), or set the css height directly.
together with the change of ctrl.itemHeight to a function
oliverhunt
@oliverhunt
Sep 29 2015 13:06
I am trying to pass some parameters to a component and render it using m.mount
but its not having any of it
Stephan Hoyer
@StephanHoyer
Sep 29 2015 13:14
@oliverhunt can you show some code plz?
oliverhunt
@oliverhunt
Sep 29 2015 13:15
Is that enough? I know it doesnt currently work but im not sure what it should be
so im trying a variety of things
Stephan Hoyer
@StephanHoyer
Sep 29 2015 13:17
you don’t have to instantiate controller and view for yourselves
oliverhunt
@oliverhunt
Sep 29 2015 13:17
what should it be?
the examples only show passing a parameterless component to m.mount
Stephan Hoyer
@StephanHoyer
Sep 29 2015 13:17
m.mount(document.getElementById("append-area"), m.component(miniOrganisation, {model: newModel}))
m.component returns a component with pre-mounted args
oliverhunt
@oliverhunt
Sep 29 2015 13:18
the weird thing with that is
the component is a bootstrap modal with a form in it
and the only thing that happens when that line runs is the bootstrap semi opaque bg is over the top of the page and the modal doesnt appear
so append-area div remains empty
Stephan Hoyer
@StephanHoyer
Sep 29 2015 13:21
gtg now. Can you plz create a jsfiddle with complete but minimal example.
I will look to it in an hour or so… if not anyone else helped you
Pablo Macias
@jpablom
Sep 29 2015 15:41
thanks @ArthurClemens :smile:
mrtracy
@mrtracy
Sep 29 2015 18:23
I have a broad question: is anybody else here using the typescript definitions provided by mithril? Because they seem to have some dramatic problems involving generics, I have trouble believing anyone's gotten them to compile correctly
well, compile in tandem with a non-trivial mithril application
i'm just wondering if my understanding of how to use mithril is somehow wrong, or if the .d.ts is wrong
@StephanHoyer Have you considered making a manipulative version of mithril-query?
I just ran into a situation of view reuse. It'd be nice to query and replace a div inside another component's view
Gilbert
@gilbert
Sep 29 2015 20:29
on second thought, a function taking children as arguments is probably more robust
Stephan Hoyer
@StephanHoyer
Sep 29 2015 20:37
yep! think so
using mq for this would hurt @lhorie's feelings I think
Gilbert
@gilbert
Sep 29 2015 20:38
=)
Rodrigo Alvarez
@Papipo
Sep 29 2015 21:04
:smile:
Isiah Meadows
@isiahmeadows
Sep 29 2015 21:59
@mrtracy What exactly are you having problems with, regarding the generics? (Most of the TS definition file in its current state was written by me.)
mrtracy
@mrtracy
Sep 29 2015 21:59
I actually have a pull request out: #805
I think the generics weren't being used correctly; there are detailed explanations in the commit messages of that pull request
Two of the bugs involved collections of generic types - if you have a collection of SomeType<T>, where the members of the collection are intended to have different types T, the collection has to be of SomeType<any> for it to work
Isiah Meadows
@isiahmeadows
Sep 29 2015 22:05
Do you at all use TypeScript's generic parameter inference? And by the way, it doesn't necessarily have to be any. As long as both types T are MithrilController instances in the <T extends MithrilController> templates (TypeScript will infer an anonymous subtype of MithrilController), it should compile.
mrtracy
@mrtracy
Sep 29 2015 22:07
that doesn't work if the collection itself is <T extends MithrilController>
like, MithrilRoutes<T extends MithrilController> required that every Component it contained by the same T
for an instance of MithrilRoutes, T can be any extension of MithrilController, but it can only be one extension of MithrilController, and every MithrilComponent in the collection has to implement that same T
and yes, we make extensive usage of this, and it just didn't compile
mrtracy
@mrtracy
Sep 29 2015 22:18
hmm, i'll have to look at that in a bit, I have no idea what the type T is in that function
oh, I know, everything in it is a valid Foo
because it extends foo explicitly
err, let me think about this
i am positive it does not compile in mithril
sorry, I have to leave for a bit
i'll get back to you
Isiah Meadows
@isiahmeadows
Sep 29 2015 22:19
Could you share a smaller example of the kind of problem you're having (link to the playground)?
ok
Rodrigo Alvarez
@Papipo
Sep 29 2015 22:53
I am doing something that is probably not a good idea. I have this "items" property, which is a m.request result. But in reality what I do is to define a lazy function that internally replaces the items value with the m.request. Otherwise this.items = Model.list() [just an example], fires the request. What I need here is to fire the request the first time items() is called. The problem is that I try to access its value before it has any :worried:
var self = this;
this.items = function() {
  self.items = opts.model.list().then(function(result) {
    if (result.length) {
      new InfiniteScroll(self, {model: opts.model});
    }
    return result;
  });

  return self.items();
}
of course that return is called too soon
Rodrigo Alvarez
@Papipo
Sep 29 2015 23:09
mmm, it seems that I can use self.items.then()
Rodrigo Alvarez
@Papipo
Sep 29 2015 23:21
This message was deleted