These are chat archives for mithriljs/mithril.js

13th
Apr 2016
James Forbes
@JAForbes
Apr 13 2016 00:33
@tivac, @Morklympious curious why you don't like underscores, I'm pretty indifferent, but underscore seems to have some solid logic behind it.
The only case I've heard for camel case is "that's how JS does it". But being consistent with badly designed API's doesn't seem like a great selling point to me.
Pat Cavit
@tivac
Apr 13 2016 02:49
I think they're harder to type and look ugly
Gilbert
@gilbert
Apr 13 2016 03:19
dashes are the best :)
khades
@khades
Apr 13 2016 03:52
var underscoure = require("underscore");
AND IT IS NOT UGLY ANYMORE
Pat Cavit
@tivac
Apr 13 2016 06:57
@khades I usually just include the lodash sub-packages I need & then give them descriptive-ish names. https://github.com/tivac/anthracite/blob/844b5d13336c06bb54f7968887d05e54263ddee1/src/types/lib/input.js#L4-L5
Stephan Hoyer
@StephanHoyer
Apr 13 2016 07:14
Hi
James Forbes
@JAForbes
Apr 13 2016 07:14
hi!
Stephan Hoyer
@StephanHoyer
Apr 13 2016 07:15
I finally got some performance issues when having a lot of elements. Just tried to {subtree: 'retain'} some elements of a list
seems mithril messes up with the elements. Tried to use key-attribute also for {subtree: 'retain'}. Seems not working
would be great to have that though
Stephan Hoyer
@StephanHoyer
Apr 13 2016 09:15
simple solution is to always render the element with the key attr and retain the inner nodes. thanks @barneycarroll
Jon Earley
@jonearley
Apr 13 2016 13:28
So I'm on the fence about using Mithril or React to render html for a large project at work. I'm impressed with Mithril, but React seems to be the go-to for front-end developers right now.
Anyone write about this choice or have their 2cents to share?
Evgeniy Labutin
@LabEG
Apr 13 2016 13:36
mithril just light, and have cool diff algorithm
Leo Horie
@lhorie
Apr 13 2016 13:36
I'm using mithril, but I'm biased :)
Stephan Hoyer
@StephanHoyer
Apr 13 2016 13:37
same here :)
Leo Horie
@lhorie
Apr 13 2016 13:39
in all seriousness though, I heard spicyj (one of the React devs) say on a few occasions that bringing runtime speed and library size down to match modern competitors is not a priority for them
Stephan Hoyer
@StephanHoyer
Apr 13 2016 13:39
Create a sample app together and take what feels better to you.
If you care about speed and simplicity you're better with mithril. If you care about large dev-community and high stack-overflow-answer-count, choose react
So also depends on the skill-level of your team
khades
@khades
Apr 13 2016 13:41
using mithril after using jquery is as simple as using mercurial after svn
Jon Earley
@jonearley
Apr 13 2016 13:48
Alright, a month or so ago I created a prototype using Mithril and React. I'm a fan of Mithril.
Stephan Hoyer
@StephanHoyer
Apr 13 2016 13:49
have you considered using emberjs :P
Leo Horie
@lhorie
Apr 13 2016 13:52
you know, the other day I wanted to update ember's dbmonster to use the latest ember version, so I went on to install ember. But then it asked me to install ember-cli. So I installed that, and... it asked me to upgrade ember-cli. So I updated it and... it asked me to update again to the same version
never managed to get the damn thing running, so I just gave up
Jon Earley
@jonearley
Apr 13 2016 13:54
Waiting for the day where that isn't the experience of using a thing 9/10 times.
Stephan Hoyer
@StephanHoyer
Apr 13 2016 13:55
Yesterday a heavy ember user raved about ember cli to me
how simple all things are
Leo Horie
@lhorie
Apr 13 2016 13:57
I would love to see that simplicity at work, because all I saw was a bunch of "Are you sure you want to overwrite file X [Y/n]" (literally dozens of those) during the ember-cli "upgrade"
Jon Earley
@jonearley
Apr 13 2016 13:59
Anyone try Redux with Mithril? https://github.com/tivac/mithril-redux
Stephan Hoyer
@StephanHoyer
Apr 13 2016 14:01
search the chat history, this was discussed at least 5 times in the past :D
Jon Earley
@jonearley
Apr 13 2016 14:01
Okay! Will do
khades
@khades
Apr 13 2016 14:07
i dont get redux at all
Leo Horie
@lhorie
Apr 13 2016 14:31
@khades redux in a nutshell:
var state = []

someElement.onclick = function() {
    dispatch({type: "ADD_THING", data: {foo: 1}})
}

function dispatch(action) {
    state = reducer(state, action)
}

function reducer(state, action) {
    if (action.type === "ADD_THING") return addReducer(state, action)
    //if (action.type === "REMOVE_THING") return removeReducer(state, action) //each reducer just returns a new state
    //and so on
    return state
}
function addReducer(state, action) {
    return state.concat(action.data)
}
redux encapsulates state and implements dispatch, the rest would be your code
Arthur Clemens
@ArthurClemens
Apr 13 2016 14:52
then you can add middleware, such as a logger to see what is going on with your state
Stephan Hoyer
@StephanHoyer
Apr 13 2016 15:00
But doesn't this create a huge depency hell and name collisioning with those type-names?
cavemansspa
@cavemansspa
Apr 13 2016 15:15
re: rewrite, is there any plans to support animation transitions better? @barneycarroll has a workaround, but was curious if there are any thoughts on supporting in rewrite a transition when an element is added / removed. e.g.
anim: {
  onadd: function() ...,
  onremove: function() ...
}
Stephan Hoyer
@StephanHoyer
Apr 13 2016 15:16
I think it's on the list
cavemansspa
@cavemansspa
Apr 13 2016 15:18
cool!
Patrik Johnson
@orbitbot
Apr 13 2016 15:25
Is anyone familiar with maquette.js? with a casual glance it seems to be a very mithril-inspired framework with animation support built in
Leo Horie
@lhorie
Apr 13 2016 15:28
@StephanHoyer the stringly-typedness is a potential issue, yes, imho
@cavemansspa yeah there will be a oncreate for enter animations and onbeforeremove for exit animations
@orbitbot yeah I saw it in the vdom benchmark, but I haven't been paying much attention to it since it's not among the fastest there
Patrik Johnson
@orbitbot
Apr 13 2016 15:35
they have a nice animation example http://johan-gorter.github.io/maquette-demo-hero/ and a reasonable tutorial for people starting out http://maquettejs.org/tutorial/01-intro.html . Haven't really dived into any details yet, but building a trivial demo with it for variation
Arthur Clemens
@ArthurClemens
Apr 13 2016 15:46
@StephanHoyer therefore you create one list of action names. A module with all of them like export const SOME_ACTION = "SOME_ACTION"
townmulti
@townmulti
Apr 13 2016 16:08
Hi everyone! New to the room😀 ...im wondering if anyone ever used Mithril with Meteorjs?
Leo Horie
@lhorie
Apr 13 2016 16:28
I wrote an article a long time ago here: http://lhorie.github.io/mithril-blog/mithril-and-meteor.html
townmulti
@townmulti
Apr 13 2016 16:36
Yea I saw that one looks good!
townmulti
@townmulti
Apr 13 2016 17:06
Was the source put on github?
Leo Horie
@lhorie
Apr 13 2016 17:30
no, the full code is in right above the conclusion
Grant Miner
@llambda
Apr 13 2016 17:39
This message was deleted
townmulti
@townmulti
Apr 13 2016 17:48
Okay thanks
Nalle Rooth
@nallerooth
Apr 13 2016 19:09
Hi, I'm pretty new to mithril but so far I think it's generally awesome. I'm currently stuck trying to write a few unit tests, using mithril-query (https://github.com/StephanHoyer/mithril-query). The problem I'm having is when I try to test a view which has an 'onclick: m.withAttr(...)' event handler. The test fails and I'm pointed to mithril.js:1465 ReferenceError: event is not defined. Have anyone else encountered/solved this problem?
Leo Horie
@lhorie
Apr 13 2016 19:16
what version are you running on?
Nalle Rooth
@nallerooth
Apr 13 2016 19:16
"mithril": "^0.2.3",
"mithril-query": "^0.9.3",
Just installed them, so that should be it
Leo Horie
@lhorie
Apr 13 2016 19:18
hmm from looking at the code, it sounds like it would happen if you triggered an event without passing an event object
Nalle Rooth
@nallerooth
Apr 13 2016 19:19
Yes, that's my understanding too
Leo Horie
@lhorie
Apr 13 2016 19:19
how are you triggering the event?
Nalle Rooth
@nallerooth
Apr 13 2016 19:20
by calling mithil-query .click([selector string])
So I guess that's where the problem is, not in mithril itself
it works perfectly in the browser
I just wanted to check if someone more experienced with mithril (and perhaps mithril-query) had encountered the problem and had a good solution
Leo Horie
@lhorie
Apr 13 2016 19:23
I think the issue is that you need to pass an object as the second argument to .click https://github.com/StephanHoyer/mithril-query/blob/master/index.js#L254
so something like .click(".foo", {currentTarget: {value: "bar"}})
Nalle Rooth
@nallerooth
Apr 13 2016 19:24
Ah, looks promising
Stephan Hoyer
@StephanHoyer
Apr 13 2016 19:24
@lhorie @nallerooth jep, that's the way to go
Nalle Rooth
@nallerooth
Apr 13 2016 19:35
@StephanHoyer Ok, thanks! An example in the README (or an additional file in the examples folder) would be helpful.
Stephan Hoyer
@StephanHoyer
Apr 13 2016 19:35
Yeah, will do this
Nalle Rooth
@nallerooth
Apr 13 2016 19:36
Other than that, I think both mithril and mithril-query are really nice to work with
Stephan Hoyer
@StephanHoyer
Apr 13 2016 19:36
I rarely use withAttr so I never have this issue. Will extend the example though
Nalle Rooth
@nallerooth
Apr 13 2016 19:36
Ah, ok
Stephan Hoyer
@StephanHoyer
Apr 13 2016 19:36
thanks!
Nalle Rooth
@nallerooth
Apr 13 2016 19:37
Thanks for your help
Stephan Hoyer
@StephanHoyer
Apr 13 2016 20:00
just added some lines to the documentation
Nalle Rooth
@nallerooth
Apr 13 2016 20:17
Great! That should help you avoid answering my question again
Patrick Kristiansen
@patrkris
Apr 13 2016 21:06
Hi everyone. Does anyone here have experience using Google Closure compiler together with Mithril?
Pat Cavit
@tivac
Apr 13 2016 21:10
@patrkris yeah, @aucelum was just talking about that recently
do a search for "closure"
Patrick Kristiansen
@patrkris
Apr 13 2016 21:13
Thanks. I have actually been using them together for a while, but was just looking for a little inspiration 😊