MCPcopy
hub / github.com/pqina/filepond / createApp

Function createApp

src/js/app/index.js:28–662  ·  view source on GitHub ↗
(initialOptions = {})

Source from the content-addressed store, hash-verified

26
27// creates the app
28export const createApp = (initialOptions = {}) => {
29 // let element
30 let originalElement = null;
31
32 // get default options
33 const defaultOptions = getOptions();
34
35 // create the data store, this will contain all our app info
36 const store = createStore(
37 // initial state (should be serializable)
38 createInitialState(defaultOptions),
39
40 // queries
41 [queries, createOptionQueries(defaultOptions)],
42
43 // action handlers
44 [actions, createOptionActions(defaultOptions)]
45 );
46
47 // set initial options
48 store.dispatch('SET_OPTIONS', { options: initialOptions });
49
50 // kick thread if visibility changes
51 const visibilityHandler = () => {
52 if (document.hidden) return;
53 store.dispatch('KICK');
54 }
55 document.addEventListener('visibilitychange', visibilityHandler);
56
57 // re-render on window resize start and finish
58 let resizeDoneTimer = null;
59 let isResizing = false;
60 let isResizingHorizontally = false;
61 let initialWindowWidth = null;
62 let currentWindowWidth = null;
63 const resizeHandler = () => {
64 if (!isResizing) {
65 isResizing = true;
66 }
67 clearTimeout(resizeDoneTimer);
68 resizeDoneTimer = setTimeout(() => {
69 isResizing = false;
70 initialWindowWidth = null;
71 currentWindowWidth = null;
72 if (isResizingHorizontally) {
73 isResizingHorizontally = false;
74 store.dispatch('DID_STOP_RESIZE');
75 }
76 }, 500);
77 };
78 window.addEventListener('resize', resizeHandler);
79
80 // render initial view
81 const view = root(store, { id: getUniqueId() });
82
83 //
84 // PRIVATE API -------------------------------------------------------------------------------------
85 //

Callers 1

createAppObjectFunction · 0.90

Calls 14

getOptionsFunction · 0.90
createInitialStateFunction · 0.90
createOptionQueriesFunction · 0.90
createOptionActionsFunction · 0.90
getUniqueIdFunction · 0.90
removeReleasedItemsFunction · 0.90
onFunction · 0.90
createOptionAPIFunction · 0.90
insertBeforeFunction · 0.90
insertAfterFunction · 0.90
createObjectFunction · 0.90
createStoreFunction · 0.85

Tested by

no test coverage detected