Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

113
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda