Is there a discontinuous function such that it is continuous on each restriction?
Take
$$f(x)= \begin{cases} 1, &\text{ if }x>0\\ 0, &\text{ if }x\le 0\\ \end{cases} $$
Then take $A_n=(-\infty,0]\cup (1/n,\infty)$
$A_n\subset A_{n+1}$, $\bigcup_{n=1}^{\infty}A_n=\mathbb R$, $f$ is continuous on $A_n$, but $f$ is not continuous on $\mathbb R$
Take a countable topological space $A=(B,\tau)$ whose finite subspaces are discrete but which is not itself discrete, e.g. $\mathbb{Q}$ with its usual topology. Take an enumeration of $B$, call it $b_n$, and set $B_n=\{ b_1,\dots,b_n \}$. Then any function from $A$ into any topological space is continuous on each $B_n$. But since $A$ is not discrete, there is a topological space $C$ and a function $f : A \to C$ such that $f$ is not continuous. (Concretely, one may take $C$ to be the Sierpinski space and $f$ to be the indicator function of a singleton which is not open.)