jeudi 20 avril 2023

my data from different adapters is stored in a single model how do i store them in different models

Ember Data: cli 4.12

I have created 2 modles user and repo and 2 adapters with same name user and repo also 2 serializers with same names.

I am calling store.findAll 2 times in a single route's model hook for both repo and user and returning the data.

when I check ember data in ember inspector I only see one model name ie user with repo data appended at bottom for same attribute names and undefined for others.

I want to know how to set models for different calls.

I dont have any code available to paste right now ask me if you dont understand this query, thank you.

i tried asking chatGPT turns out its not great for ember framework and keeps givng me weired codes probably of older cli and new ones mixed




mercredi 12 avril 2023

caught TypeError: requireNode is not a function at window.require

''' ( function (win) => { const { requireNode, require: requireAMD } = win; if (requireAMD) { win.require = (...args) => { try { return requireAMD(...args); } catch(error) { if (error.toString().includes('Error: Could not find module')) { return requireNode(...args); } console.error(error); } }; Object.assign(win.require, requireNode, requireAMD); } else {win.require = requireNode;` } })(window); '''

Facing error for requireNode as 'requireNode is not defined' in catch block return requireNode(...args);.




lundi 10 avril 2023

How to implement infinite scroll in columns?

Here I have a work scenario where I need to add columns based on Dates and granularities (last 48 hrs - 15 mins).

In this case, I need to create - 2 Columns (eg- 10/04/2023 and 09/04/2023) and 192 Children columns (96 children each (15min x 4 x 24))

So all the above 192 columns will get created dynamically based on user selection.

So here our problem comes into the picture while creating 192 columns at once definitely my screen will get freeze for a while.

To make it efficient I want to implement infinite scrollable columns so that it doesn't need to render a large number of columns at once.

Any suggestions will be appreciated!!




dimanche 2 avril 2023

Nothing is getting displayed on webpage while using ember.js

I am building a simple web application using ember.js ,but in the webpage ,nothing is displayed ,in the console the following error is being displayed.I am using mirage as the back end

rsvp.js:26 Uncaught TypeError: Cannot read properties of undefined (reading 'sentence')
    at Temp.title (post.js:10:1)
    at eval (mirage-esm.js:485:24)
    at Array.forEach (<anonymous>)
    at sortAttrs (mirage-esm.js:481:22)
    at Factory.build (mirage-esm.js:388:16)
    at EmberServer.build (mirage-esm.js:7325:24)
    at EmberServer.create (mirage-esm.js:7397:30)
    at EmberServer.createList (mirage-esm.js:7466:31)
    at Object._default [as default] (default.js:9:1)
    at EmberServer.config (mirage-esm.js:7152:37

I am adding some files code here for the understanding , application.hbs


<div class ="jumbo">
<h2 id="title">
    My ember blog
    
</h2>
</div>


posts.js under templates



<ul>
  
    <li>
      
    </li>
  
</ul>

post.js under model folder in app

import Model, { attr } from '@ember-data/model';

export default class PostModel extends Model {
  @attr title;
  @attr body;
  @attr('date') publishedAt;
}

posts under routes in app folder

import Route from '@ember/routing/route';

export default class PostsRoute extends Route {
  model() {
    return this.store.findAll('post');
  }
}

posts.js under factories under mirage folder

import { Factory } from 'miragejs';

import faker from '@faker-js/faker';

export default Factory.extend({
  title() {
    return faker.lorem.sentence();
  },

  body() {
    return faker.lorem.paragraph();
  },

  publishedAt() {
    return faker.date.past();
  },
});

So these are the files that I have used in this project .and if you know the structure of emp app ,you will be able to understand these files. My ember-cli version is 3.24.0 node: 14.21.3 os: linux x64 Please help me in resolving this ,I am beginner in ember