add a 'safeApply' function to avoid  during the apply or digest phases