Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!