Wavelet bases in rearrangement invariant function spaces