F
F
feniksdv2020-11-14 22:06:15
Vue.js
feniksdv, 2020-11-14 22:06:15

How to tell Vue.js that queue:work has finished?

Hello.

There is such a function:

update: function () {
         //запускаем выполнение скрипта в потоке
          axios.get('/show/'+ this.site.site +'/update').then((response) =>{
              this.urldata1 = response.data;
              //тут нужно сообщить что воркер выполнил работу и после этого запустить код ниже. 
              if (response.status === 200) {
                  for(var i = 0; i<this.urldata.keyAll.length; i++) {
                       axios.get('/show/' + this.site.site + '/getJson/1').then((response) => {
                          this.urldata = response.data;
                            });
                        }
                    }
                });
            },


Here is the file that starts the second thread

namespace App\Jobs;

    use App\Models\AddProject;
    use Illuminate\Bus\Queueable;
    use Illuminate\Contracts\Queue\ShouldQueue;
    use Illuminate\Foundation\Bus\Dispatchable;
    use Illuminate\Queue\InteractsWithQueue;
    use Illuminate\Queue\SerializesModels;
    use Illuminate\Support\Facades\Auth;

    class JobCreatCheck implements ShouldQueue
    {
        use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

        protected $parameters;

        /**
         * Create a new job instance.
         *
         * @return void
         */
        public function __construct($parameters)
        {
            $this->parameters = $parameters;
        }

        /**
         * Execute the job.
         *
         * @return void
         */
        public function handle()
        {
            //переменые с контроллера
            $url = $this->parameters['url'];
            $site = $this->parameters['site'];
            $key_value = $this->parameters['key_value'];
            $auth_id = $this->parameters['auth_id'];
            $todayDate = $this->parameters['todayDate'];

           //тут код вы полнения убрал для краткости

            //сохранить результат в БД
            $flight = AddProject::updateOrCreate(
                [
                    'user_id' => $auth_id,
                    'site' => $site,
                    'textarea' => $key_value,
                    'date' => $todayDate
                ],
                [
                    'num_check' => $saveNumCheck
                ]
            );

            $flight->save();
        }
        public function failed($exception)
        {
            echo $exception;
        }
    }


I have already broken my head how to convey to Vue that the worker has completed the work. Any ideas how this can be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zorca, 2020-11-14
@feniksdv

For example, check the status of a task every ten seconds.
The second option is to send an Event upon completion and pass it to the front via websockets:
https://pusher.com/tutorials/monitoring-laravel-ba...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question