Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Richard Butler
@RickButler
You are using webpack so it really doesn't matter. Webpack can understand either.
if you tried to use that in an environment that onyl understood commonjs style require module.export, then the import wouldn't work...
v1rt
@v1rt
ah got it
going back to the error I posted regarding constructor, what are your thoughts? I'm going to update my code copy to see the changes my teammate made. He said it fixes the error
however, i'm worried about what's been happening since looks like the fixes here are all hackish
Richard Butler
@RickButler
I think that maybe something besides ampersand-state was getting exported. So maybe an empty object or something.
v1rt
@v1rt
got it
i'll take a look at it deeper
i'll put a breakpoint
StompyNZ
@StompyNZ
hello, i'm building my first ampesandjs app and having some trouble with a load on demand collection that I want to cross reference properties from another collection. Specifically i have an id field in my main collection, and I want to map that to a name field on the other collection by id reference. The solution I have works most of the time, but on occasion has no data in the second collection (I assume an async race condition causes it)
the render function on my page object is:
render: function () {
    if (!app.itemclasses.length) {
      app.itemclasses.fetch();
    };
    this.renderWithTemplate();
    this.renderCollection(this.collection, collectionView, this.queryByHook('recipe-list'));
    if (!this.collection.length) {
      this.fetchCollection();
    };
  },
are there some examples of how to build an app with rest-collections and cross references? having no luck googling for them
oh, and the derived property on my recipe is:
ItemClassName: {
      deps: ['Type'], fn: function () {
        var itemclass = app.itemclasses.get(this.Type);
        return itemclass != null ? itemclass.Name : '';
      },
      cache: false
    }
Richard Butler
@RickButler
Use a subview to render the collection in, then you can use waitFor on the subview declaration to wait for
The collection to return values
StompyNZ
@StompyNZ
hmm, tried a number of different subviews setups and such but can't get it to work. must be something obvious i'm missing. Thanks for the tip, i'll keep hacking away at it
Richard Butler
@RickButler
@StompyNZ It's hard to say without seeing where the two collections are declared/fetched etc. I can see the one app.itemclasses.fetch() but probably need to see where they both get fetched etc. I assume the model with the derived ItemClassName is looking at the value of app.itemclasses before the fetch is done. You can either trigger changes on the models when app.itemclasses finishes fetch, or figure out a way to have you subview use a derived or some condition to waitFor both to be fetched.
@StompyNZ if you have the code on github I can take a look.
StompyNZ
@StompyNZ
thanks richard, I've just uploaded the code to here: https://github.com/CodestormNZ/BadCompanySMAmp
thats the specific page in question ;)
StompyNZ
@StompyNZ
btw im new to node and haven't used backbone. Mostly worked with knockout for front end library
Richard Butler
@RickButler
@StompyNZ I think it can be done with a subview and waitfor I will take a look when I get home.
StompyNZ
@StompyNZ
ok thanks for that :)
Richard Butler
@RickButler
@StompyNZ I couldn't really test it, i get a lot of API failures, but something like this https://gist.github.com/RickButler/a0a1137e4dea01a2dbef4a37853ceb8f
StompyNZ
@StompyNZ
thanks richard, ill test it out in about 3 hours when I get home from work :)
the api server is a game server and very basic webserver that doesnt allow cors so cant make it available for testing remotely
StompyNZ
@StompyNZ
@RickButler Thanks heaps, works perfectly :)
Richard Butler
@RickButler
@StompyNZ no problem, I have some abstractions that might help with that. I have a property on my base model that gets auto set after fetch returns. Working on putting it on git so you and others can take a look.
StompyNZ
@StompyNZ
nice :)
this app im working on is partly to learn ampersandjs because my work wants to switch over to it, but its a huge project so getting a good file structure worked out will be the next step
Richard Butler
@RickButler
@StompyNZ another thing to keep in mind is the ampersand cli generated project has out of date dependencies
Richard Butler
@RickButler
in your project for instance the cli generates ampersand-model in the package.json with 5.0.3, ampersand is on 8.0.1
ampersand-model* is on 8.0.1
I should probably submit a PR to update the CLI...
Calvin
@oakypokey
Hey, I'm trying to find documentation on findWhere but I keep on running into dead links?
Richard Butler
@RickButler
@oakypokey are you referring to findWhere on an ampersand collection? If so that is just a proxy to lodash findWhere.
Lodash where rather
Richard Butler
@RickButler
I'm sorry still wrong lol it uses lodash filter.
Kelly Nelson
@pnwnelson
Hello. Hope this place is still monitored? I'm new to ampersand and still green in javascript overall, but I'm wondering if I should be using ampersand-rest-collection to create models from a local json file? I currently am, but it doesn't seem to be dropping anything into the model. I also am following along in the HumanJavascript video series and am trying to duplicate, but with local json rather than an external api. Any help is appreciated.
Min Thant Sin
@minthantsin_gitlab
@pnwnelson Same here, I'm new to ampersand.
Samuil Gospodinov
@samuil4
@pnwnelson The rest collection is intended to be used with an actual API, you can easily run a node json-rest plugin like this one https://github.com/typicode/json-server to simulate such.
Kelly Nelson
@pnwnelson
@samuil4 Thanks for the reply. I'm going to be pulling data from the json file for production so I need a permanent solution - unless I'm misunderstanding. Would using ampersand-collection handle this?
Kelly Nelson
@pnwnelson
As a relative novice in this, I always struggle understanding the terminology to figure out what tool to use for what I'm trying to do. Reading the docs, it sounds as if maybe I should be using &-state instead of &-model, to create a model and a collection for data coming from a local json file. Is this correct? Yet I see others using &-model for use with local json files.
Brian Kenny
@brianvegan
Guys, rudimentary question: how do I add new JS/CSS to the generated code file[s]? (Appname).nonCached.js and .nonCached.css
Richard Butler
@RickButler
@brianvegan We would need to see your project/build process. Are you using a sample project from somewhere, or do you have your code on github?
Brian Kenny
@brianvegan
did some noob sleuthing, was in moonbootsConfig.js, ty :D