I
I
Ivan Antonov2019-07-02 16:01:51
Java
Ivan Antonov, 2019-07-02 16:01:51

Where can I get gradlew?

I looked at the Gradle website, but did not understand where to get the Gradle Wrapper from.
Tell a noob.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
I
illuzor, 2019-07-02
@antonowano

In IDEA/Android Studio projects this wrapper is created automatically.
But you can create it manually by calling gradle wrapper

M
Maxim, 2017-09-13
@hazratgs

If I understood your colleague correctly, then it was not about the need to call asynchronous functions through setTimeout, but it was just an example of how to make some piece of "type asynchronous".
His argument was that instead of calling dispatch from a closure (obtained with redux-thunk, for example), he called store.dispatch directly (that is, on the store object, and that store would be imported in each file).
In this case, redux-thunk has one distinct advantage - you don't have to import store in every file.
Otherwise, everything is very clearly written in the answer of Dan Abramov, who brought holymotion .
In short, you need a dispatch function, because it is through it that you "dispatch" your actions. You cannot write in an asynchronous response:

...
axios.get('/user')
      .then(res => {
        // успешно получили данные
        dispatch({ // <-- здесь вы вызываете функцию dispatch, а если она к вам не пришла в анонимной функции, с помощью redux-thunk, то октуда вы ее возьмете?
          type: GET_PROFILE_SECCUESS
          payload: res.data
        })
      })
...

Therefore, in each action creator that is asynchronous, you would be required to pass, in addition to the arguments you need, the dispatch function from your container. Which is not convenient. (this is all on the stackoverflow link, but in more detail)

I
Islam Ibakaev, 2017-09-13
@devellopah

I would argue that redux-thunk, redux-saga, or some other "solution" for organizing side effects is not a necessary dependency for any application written in reactjs.
Just like redux itself is not necessary. But if your application needs a state tool (redux), it automatically follows that it also needs a side effects tool.
In redux-thunk, you dispatch a function as if it were an action. It is very important. In the container, regardless of the "nature" of the action, you will write this.props.dispatch(whateverAction).
And your colleague, on the contrary, will be forced to dispatch synchronous actions through this.props.dispatch(syncAction), and asynchronous ones simply by calling the function containing setTimeout.
Somehow it’s not very beautiful, and the container itself does not need to know which actions are synchronous and which are asynchronous.

H
Hydrock, 2018-05-25
@Hydrock

I also suffer from this issue. Personally, on the contrary, I don’t like that logic is taken out in action creators. Sagas seem to fit better.

B
Boris Cherepanov, 2019-12-12
@xakplant

Indeed, most likely it is about the organization of the code.
If we are making our react application, it is possible that one day we will have to change the store. It's generally bad form to use dispatch on the component itself without wrapping it in a HOC. After all, this immediately makes it impossible to reuse. For example, we have a component that renders some kind of list and uses redux. In order for us to reuse it correctly, do this:

import React, { Component } import 'react';
import List from './List'; // Список
import { connect } from 'react-redux'
import { mutatinList } from './actions'; // Какой-то action

class ListContainer extends Component{
  render(){
    return(
      <List {...this.props} />
    )
  }
}

const mapStateToProps = (state) => ({
    list: state.list
})

const mapDispatchToProps = {
  mutatinList: mutatinList
}

export default connect(mapStateToProps, mapDispatchToProps)(ListContainer);

If we want to reuse our list, then we don’t have to rewrite the component itself, but we can only write a new HOC
. I also wrote a short article on this topic

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question