@@ -11,9 +11,14 @@ import {bindall} from "./utils.js";
1111
1212function unsubscribe ( method , cmd ) {
1313 return function ( ) {
14- let resolve = arguments [ arguments . length - 1 ] ;
14+ let resolve ;
1515 let reject = ( ) => { } ;
16- let args = Array . prototype . slice . call ( arguments , 0 , arguments . length - 1 ) ;
16+ let args = Array . prototype . slice . call ( arguments , 0 , arguments . length ) ;
17+ for ( let i = args . length - 1 ; i >= 0 ; i -- ) {
18+ if ( typeof args [ i ] === "function" ) {
19+ resolve = args . splice ( i , 1 ) [ 0 ] ;
20+ }
21+ }
1722 let msg = {
1823 cmd : cmd || "view_method" ,
1924 name : this . _name ,
@@ -28,9 +33,14 @@ function unsubscribe(method, cmd) {
2833
2934function subscribe ( method , cmd ) {
3035 return function ( ) {
31- let resolve = arguments [ arguments . length - 1 ] ;
36+ let resolve ;
3237 let reject = ( ) => { } ;
33- let args = Array . prototype . slice . call ( arguments , 0 , arguments . length - 1 ) ;
38+ let args = Array . prototype . slice . call ( arguments , 0 , arguments . length ) ;
39+ for ( let i = args . length - 1 ; i >= 0 ; i -- ) {
40+ if ( typeof args [ i ] === "function" ) {
41+ resolve = args . splice ( i , 1 ) [ 0 ] ;
42+ }
43+ }
3444 let msg = {
3545 cmd : cmd || "view_method" ,
3646 name : this . _name ,
0 commit comments