Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
What's the best way to reuse some methods between two different components with AlpineJS?

Let's say I've two different components who share two selects that receive their data from the server through a controller:

function component1() {
    return {
        someArray: [],
        someString: '',
        someBoolean: false,
        selectMethod1: function() {
            window.livewire.emit('get_select_method1');
        },
        selectMethod2: function(someParameter, anotherParameter) {
            window.livewire.emit('get_select_method2');
        }
    }
}

function component2() {
    return {
        someInt: 1,
        selectMethod1: function() {
            window.livewire.emit('get_select_method1');
        },
        selectMethod2: function(someParameter, anotherParameter) {
            window.livewire.emit('get_select_method2');
        }
    }
}

In the above example I'm looking for the best way to reuse the methods "selectMethod1" and "selectMethod2" in both components (without the need to create a third element for the selects).

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda