Assume that there are two topological spaces $X,Y$ and a function $f:X\rightarrow Y$. Furthermore, assume that there exists a collection of sets $\mathcal{B}$ such that
$\bigcup_{B\in \mathcal{B}} B = X,$
and for each $B \in \mathcal{B}$ the restriction $f|_B$ is continuous with respect to the subspace topology.
Is this enough to say that $f$ is continuous on the whole space?