Continuity on a union

This is true for all spaces $Y$ if and only if $X$ has the colimit topology with respect to the spaces $X_i$, more traditionally known as the coherent topology. A counterexample is given by a countable set $X$ equipped with the cofinite topology and $X_i$ an increasing sequence of finite sets whose union is $X$ (for example $X = \mathbb{Z}, X_i = [-i, i]$). The colimit topology with respect to the $X_i$ is the discrete topology.

Edit: $\overline{ X_i} = X$ (which is equivalent to $\overline{ X_1 } = X$) is also not enough to guarantee that you have the coherent topology. Take the above example $X = \mathbb{Z}, X_i = [-i, i]$ with the cofinite topology and remove all of the non-empty open sets that don't include $\{ 0 \}$ (so a combination of the cofinite topology and the particular point topology). Then each $X_i$ is dense but the above problem still stands: the colimit topology with respect to the $X_i$ is the particular point topology on $\{ 0 \}$.


No, it's not true. Take $f(0) = 0$ and $f(x) = 1$ if $x \neq 0$. If $X_{n} = \{0,\frac{1}{n},\frac{1}{n-1},\ldots,1\}$ and $X = \bigcup_{n} X_n$ is viewed as a subset of $\mathbb{R}$ then $f|_{X_n}$ is definitely continuous, but $f$ is clearly not continuous as a function $f:X \to \mathbb{R}$.

In fact, in order for your condition to hold for all $f: X \to Y$, where $Y$ is allowed to be any space, it is necessary and sufficient that your space $X$ be equipped with the final topology induced by the inclusions $X_{i} \to X$.