These are chat archives for CodeHubOrg/discussions

15th
Mar 2017
Tim Handy
@TimHandy
Mar 15 2017 14:52
help :-( Can anyone tell me what I'm doing wrong here please? I'm attempting to export this file and import it to this test file and then when I run my tests it complains that model.shuffle is not defined.
have I got a typo somewhere or am I doing it all wrong?
Jack Leigh
@leighman
Mar 15 2017 15:04
@TimHandy Babel 5 or 6?
Paul
@paulfourniercarey
Mar 15 2017 15:04
Hello all.
I am new to code hub and hoping to come along to the javascript 101 meetup on the 21st.
I seem to have got the local js101 site up and running from github, it looks very basic css-wise, that right?
Jack Leigh
@leighman
Mar 15 2017 15:06

@TimHandy I think you want:

export default {foo: "blah"}

and

import model from "./model.js"
Been a while since I used import style
Or
import {shuffle} from "./model.js"
Tim Handy
@TimHandy
Mar 15 2017 15:34
So export default {}' andimport model from './model.js'` worked, though I still am none the wiser as to how these things work... it seems every time I do it I have to do it a different way to get it to work... Grrr. Thanks Jack.
@paulfourniercarey Hi Paul. that page went up just last week as a holding page. I think it's a bit of an inside joke...very 90's styling. I don't believe anyone has had time to work on it yet. I'm sure you'll be very welcome at the meetup :-)
Jack Leigh
@leighman
Mar 15 2017 15:40
@TimHandy Almost always modules will export an object of functions which you can import as one thing or pick bits of as per the two above examples
the * syntax is for in the rare case where the module exports separate functions and you want to group them into an object in your own code
the export default model = {} would probably still work (although the name model there only means anything within the file), I think it's the import where you had it wrong
Tim Handy
@TimHandy
Mar 15 2017 15:42
I must have tried every combination from about 10 websites including MDN, apart from the one that worked! I'll make a note of those in my notes for next time. :-)
wingedeel
@wingedeel
Mar 15 2017 16:03
I've found this a good example of exports/imports (great site for ES6 reference)
Tim Handy
@TimHandy
Mar 15 2017 16:50
thanks Anne. I've made some additional notes on that.
I'm attempting to refactor my spaghetti code from some months ago into pure, testable functions. It's slow going unpicking it all, but hopefully I'm learning something.
wingedeel
@wingedeel
Mar 15 2017 17:06
I love a good refactor. I'm sure you will be learning loads @TimHandy. Maybe you can show us something at the next js101.
Tim Handy
@TimHandy
Mar 15 2017 17:23
Yeah, could do... i have a whole 6 tests now! woo hoo.
wingedeel
@wingedeel
Mar 15 2017 17:30
Fab!
Gicela
@Gicela
Mar 15 2017 18:59
OT: Just read that Gitter has been acquired by GitLab http://blog.gitter.im/
Katja Durrani
@katjad
Mar 15 2017 22:44
hope it can still be linked to our Github repo ;) @TimHandy 6 tests ๐Ÿ‘at least you write them, I still don't - interesting about the import report Thanks @leighman for clarifying!
@paulfourniercarey yes styles very basic. Feel free to make a pull request ;) looking forward to meeting you on Tuesday