Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P62264
common.js to reproduce T364518
Active
Public
Actions
Authored by
Sportzpikachu
on May 9 2024, 6:45 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Tags
None
Referenced Files
F51489788: common.js to reproduce T364518
May 9 2024, 6:45 PM
2024-05-09 18:45:49 (UTC+0)
Subscribers
None
mw
.
loader
.
using
(
[
'vue'
,
'pinia'
],
(
require
)
=>
{
const
vue
=
require
(
'vue'
);
// vue-demi fix, uncomment to enable
/*
vue.set = function ( target, key, val ) {
if ( Array.isArray( target ) ) {
target.length = Math.max( target.length, key );
target.splice( key, 1, val );
return val;
}
target[ key ] = val;
return val;
};
vue.del = function ( target, key ) {
if ( Array.isArray( target ) ) {
target.splice( key, 1 );
return;
}
delete target[ key ];
};
*/
const
pinia
=
require
(
'pinia'
);
const
useCounter
=
pinia
.
defineStore
(
'counter'
,
()
=>
{
const
count
=
vue
.
ref
(
0
);
const
increment
=
()
=>
count
.
value
++
;
return
{
count
,
increment
};
}
);
const
app
=
vue
.
createMwApp
(
{
setup
()
{
const
counter
=
useCounter
();
return
()
=>
vue
.
h
(
'button'
,
{
onClick
:
()
=>
counter
.
increment
()
},
[
'Count: '
,
counter
.
count
,
]
);
},
}
);
app
.
use
(
pinia
.
createPinia
()
);
app
.
mount
(
'#app'
);
const
hot
=
{
data
:
{},
};
const
hmr
=
pinia
.
acceptHMRUpdate
(
useCounter
,
hot
);
$
(
'<button>Trigger HMR</button>'
).
one
(
'click'
,
()
=>
{
hmr
(
{
useCounter
:
pinia
.
defineStore
(
'counter'
,
()
=>
{
const
count
=
vue
.
ref
(
0
);
const
increment
=
()
=>
(
count
.
value
+=
2
);
return
{
count
,
increment
};
}
),
}
);
}
).
insertAfter
(
'#app'
);
}
);
Event Timeline
Sportzpikachu
created this paste.
May 9 2024, 6:45 PM
2024-05-09 18:45:49 (UTC+0)
Sportzpikachu
mentioned this in
T364518: Pinia ResourceLoader module does not implement vue-demi's functions
.
May 9 2024, 6:53 PM
2024-05-09 18:53:15 (UTC+0)
Log In to Comment