jeudi 17 mars 2022

Ember has-block to detect empty block

In ember octane, is there a way to detect is not an empty string?

The has-block function will return true if we use an empty component like this <IntakeFormElement></IntakeFormElement> while false when <IntakeFormElement/>.

How do I get both <IntakeFormElement></IntakeFormElement> and <IntakeFormElement/> return false?


    Content: 

    No block

Ember Twiddle code:

https://ember-twiddle.com/7bf99058ec9f125b8b88dd73350ad3b4?openFiles=templates.components.intake-form%5C.hbs%2Ctemplates.components.intake-form%5C.hbs




mercredi 16 mars 2022

EmberJS 4.2 + SocketIO 4 setup

In my application, when I refresh the page, sometime I can't able to get data with SocketIO.

I think the event emitter was triggered before socket connecting to server.

SocketIO Code:

import { io } from 'socket.io-client';

export default class SocketIoService extends Service {

  @action io() {
    return io('http://localhost:3030', {});
  }
}

Data receiving Code:

export default class DataService extends Service {
  @service('socket-io') socket;

  @tracked data;

  @action getData() {
    let socket = this.socket.io();

    socket.on('data-response', (data) => {
      this.data = data
    })

    socket.emit('data-request');
  }
}

I'm new to EmberJS, I didn't find any latest class(oops) based example code.

Also suggest any boilerplate or open source with latest version please.




dimanche 13 mars 2022

Issue with ember-cli-rails and puma-dev

Just getting started with a rails api and ember frontend. I'm using ember-cli-rails and puma-dev. I'm getting an error when visiting the localhost at .test. I'm not sure what is causing it, or if it's due to both the front and back end bring set to "/".

Any point in the right direction would be appreciated!

NoMethodError undefined method `has_key?' for nil:NilClass Extracted source (around line #19):

  def action_encoding_template(action) # :nodoc:
    *if @_parameter_encodings.has_key?(action.to_s)*
      @_parameter_encodings[action.to_s]
    end
  end

https://github.com/wjacobs71086/keenmind




samedi 5 mars 2022

Ember Query Parameter cant send value in hash

I cant send the query param value to call set pageno value

template code :


  <LinkTo @route="getServices" @query=" }} ></LinkTo>

controller :

export default class GetServicesController extends Controller {
  queryParams = ['pageno'];

  @tracked pageno = "1";

  
}