Let $A,B \subseteq X$ be closed in $X$ with $A \cup B = X$.
Suppose there exists a function, $f: X \rightarrow Y$, with both $f {\restriction_{A}}: A \rightarrow Y$ and $ f {\restriction_{B}}: B \rightarrow Y$ continuous.
Prove that $f$ is continuous.
Proposed proof:
It is sufficient to show that if $F \subseteq Y$ is closed in $Y$, then $f^{-1}(F)$ is closed in $X$.
Let $F \subseteq Y$ be closed in $Y$. By continuity of $f{\restriction_{A}}$ and $f{\restriction_{B}}$, one has it that $f^{-1}{\restriction_{A}}(F)$ and $f^{-1}{\restriction_{B}}(F)$ are closed in their subspace topologies.
I.e. $f^{-1}{\restriction_{A}}(F) = A \backslash (\bigcup_\limits{{i \in I}}U_i \cap A) $ and similarly, $f^{-1}{\restriction_{B}}(F) = B \backslash (\bigcup_\limits{{j \in J}}U_j \cap B) $
Also being restrictions of $f$ we have that: $$f^{-1}{\restriction_{A}}(F) = f^{-1}(F) \cap A$$ $$f^{-1}{\restriction_{B}}(F) = f^{-1}(F) \cap B$$ $\Rightarrow f^{-1}{\restriction_{A}}(F) \cup f^{-1}{\restriction_{B}}(F) = (f^{-1}(F) \cap B) \cup (f^{-1}(F) \cap A) = f^{-1}(F) \cap (A \cup B) = f^{-1}(F)$
Since $A \cup B = X$.
It now suffices to show that $f^{-1}{\restriction_{A}}(F) = A \backslash (\bigcup_\limits{{i \in I}}U_i \cap A) $ is closed in $X$ and similarly for $f^{-1}{\restriction_{B}}(F)$, as the union of two closed sets is closed.
$$X \backslash f^{-1}{\restriction_{A}}(F) = X \backslash (A \backslash (\bigcup_\limits{{i \in I}}U_i \cap A)) $$
$$= X \backslash ((A \backslash \bigcup_\limits{{i \in I}}U_i) \cup (A \backslash A) $$ $$= (X \backslash A) \cup \bigcup_\limits{{i \in I}}U_i $$
Which is just the union of open sets in X (since A is closed by assumption).
Hence $X \backslash f^{-1}{\restriction_{A}}(F)$ is open $\Rightarrow f^{-1}{\restriction_{A}}(F)$ is closed.
One can show $f^{-1}{\restriction_{B}}(F)$ is closed similarly, thereby completing the proof.
What is the meaning of the family $(U_i)_{i \in J}$ ???
And why so complicated ??
If $f^{-1}{\restriction_{A}}(F)$ is closed in the subspace topology of $A$, then there is a closed subset $Z$ of $X$ such that $f^{-1}{\restriction_{A}}(F)=A \cap Z$ .
Since $A$ is closed (in $X$), we have that $f^{-1}{\restriction_{A}}(F)=A \cap Z$ is closed in $X$.